Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2.0] Release #302

Merged
merged 157 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
1858350
[kbss-cvut/termit-ui#449] Add Excel template file for importing vocab…
ledsoft Jun 10, 2024
3e2b47f
[kbss-cvut/termit-ui#449] Allow downloading Excel import template file.
ledsoft Jun 18, 2024
aba8fe0
[kbss-cvut/termit-ui#449] Add updated Excel template with value lists…
ledsoft Jun 18, 2024
c402ab1
[kbss-cvut/termit-ui#449] Make Excel import template file configurable.
ledsoft Jun 18, 2024
d36d00e
[kbss-cvut/termit-ui#449] Refactor SKOSImporter - provide a common Vo…
ledsoft Jun 19, 2024
6020675
[kbss-cvut/termit-ui#449] Resolve vocabulary importer based on provid…
ledsoft Jun 19, 2024
df2800d
[kbss-cvut/termit-ui#449] Implement import of basic attributes from E…
ledsoft Jun 25, 2024
839b850
[kbss-cvut/termit-ui#449] Support importing multilingual Excel withou…
ledsoft Jun 25, 2024
3ae9137
[kbss-cvut/termit-ui#449] Fix properties file encoding issues.
ledsoft Jun 25, 2024
84c8d0a
[kbss-cvut/termit-ui#449] Add Excel template file for importing vocab…
ledsoft Jun 10, 2024
30e68db
[kbss-cvut/termit-ui#449] Allow downloading Excel import template file.
ledsoft Jun 18, 2024
e141111
[kbss-cvut/termit-ui#449] Add updated Excel template with value lists…
ledsoft Jun 18, 2024
789ae83
[kbss-cvut/termit-ui#449] Make Excel import template file configurable.
ledsoft Jun 18, 2024
dc3bace
[kbss-cvut/termit-ui#449] Refactor SKOSImporter - provide a common Vo…
ledsoft Jun 19, 2024
bf234d7
[kbss-cvut/termit-ui#449] Resolve vocabulary importer based on provid…
ledsoft Jun 19, 2024
7a369ca
[kbss-cvut/termit-ui#449] Implement import of basic attributes from E…
ledsoft Jun 25, 2024
733bbe4
[kbss-cvut/termit-ui#449] Support importing multilingual Excel withou…
ledsoft Jun 25, 2024
905a370
[kbss-cvut/termit-ui#449] Fix properties file encoding issues.
ledsoft Jun 25, 2024
0765368
Merge remote-tracking branch 'origin/kbss-cvut/termit-ui#449-excel-im…
ledsoft Jul 25, 2024
e0ed345
[Fix] Add missing test Excel files.
ledsoft Jul 25, 2024
c986a6c
[kbss-cvut/termit-ui#449] Handle term hierarchies in Excel import.
ledsoft Jul 25, 2024
4edcde2
[kbss-cvut/termit-ui#449] Handle term relationships within a vocabula…
ledsoft Jul 25, 2024
4be6c03
[kbss-cvut/termit-ui#449] Fix Excel importing issues after testing wi…
ledsoft Jul 25, 2024
7f186d6
[kbss-cvut/termit-ui#449] Handle null cells in imported Excel.
ledsoft Jul 25, 2024
fe32cbe
[kbss-cvut/termit-ui#449] Handle languages other than Czech and Engli…
ledsoft Jul 29, 2024
44ceee6
[kbss-cvut/termit-ui#449] Support sheets with identifier column and u…
ledsoft Jul 29, 2024
e82ff37
[kbss-cvut/termit-ui#449] Use semicolon when splitting multiple value…
ledsoft Jul 29, 2024
cccba4e
[kbss-cvut/termit-ui#449] Fix broken test (change of delimiter from ,…
ledsoft Jul 29, 2024
60335cb
[kbss-cvut/termit-ui#449] Reuse imported term identifier when available.
ledsoft Aug 5, 2024
e1f0905
[kbss-cvut/termit-ui#449] Ensure all available rows in a sheet are pr…
ledsoft Aug 5, 2024
3aaccd6
Removal of non-empty vocabularies
lukaskabc Aug 2, 2024
fa79893
PR fixup
lukaskabc Aug 12, 2024
47817b5
[Fix] Prevent ConcurrentModificationException in ScheduledContextRemo…
ledsoft Aug 12, 2024
5c97997
[kbss-cvut/termit-ui#449] Ensure existing vocabulary can be reimported.
ledsoft Aug 12, 2024
0a54b09
[kbss-cvut/termit-ui#449] Support identifier-based references to term…
ledsoft Aug 12, 2024
f756fa5
[kbss-cvut/termit-ui#449] Document ExcelImporter.
ledsoft Aug 12, 2024
e2683ed
[kbss-cvut/termit-ui#449] Support resolving term state and types from…
ledsoft Aug 12, 2024
cdeeac5
Merge branch 'master' into kbss-cvut/termit-ui#449-excel-import
ledsoft Aug 12, 2024
94468a1
Merge branch 'development' into kbss-cvut/termit-ui#449-excel-import
ledsoft Aug 12, 2024
c95ab19
Merge pull request #286 from kbss-cvut/kbss-cvut/termit-ui#449-excel-…
ledsoft Aug 12, 2024
35e4134
[kbss-cvut/termit-ui#449] Fix NPX in ExcelImport.
ledsoft Aug 13, 2024
8c9d086
[HotFix] Allow disabling automatic text analysis of all vocabulary te…
ledsoft Aug 13, 2024
2bb75b5
[kbss-cvut/termit-ui#449] Set imported term state to configured initi…
ledsoft Aug 17, 2024
7d7509e
[kbss-cvut/termit-ui#449] Modify Excel template download so that it (…
ledsoft Aug 17, 2024
a267a2d
[Ref] Move all TypeAwareResource implementations into the util package.
ledsoft Aug 17, 2024
8b1a07d
[kbss-cvut/termit-ui#449] Throw exception when sheet contains duplica…
ledsoft Aug 19, 2024
01c8be4
[kbss-cvut/termit-ui#449] Throw exception when sheet contains duplica…
ledsoft Aug 26, 2024
9087621
[kbss-cvut/termit-ui#449] Use first state and type encountered for a …
ledsoft Aug 29, 2024
e65e256
[kbss-cvut/termit-ui#449] Resolve imported term identifier before per…
ledsoft Aug 29, 2024
dd376ba
[kbss-cvut/termit-ui#449] Prevent import of term with existing label …
ledsoft Aug 29, 2024
2722583
[kbss-cvut/termit-ui#449] Add some explanatory javadoc.
ledsoft Aug 29, 2024
01d9e1a
[Upd] Dependency updates.
ledsoft Aug 29, 2024
9316518
[kbss-cvut/termit-ui#449] Add missing type and state selection lists …
ledsoft Aug 30, 2024
c1bf874
[kbss-cvut/termit-ui#449] Support multiple types per term in Excel im…
ledsoft Aug 30, 2024
f8d8cdf
websocket endpoint implementation
lukaskabc Aug 28, 2024
36de8cb
websocket testing
lukaskabc Aug 29, 2024
17622a8
test reset
lukaskabc Aug 29, 2024
e6ab64b
fix socket authorization
lukaskabc Aug 29, 2024
0ced060
exception handling, fix message with headers
lukaskabc Aug 30, 2024
b693f40
websocket integration test
lukaskabc Sep 3, 2024
88dda5b
fix websocket integration test
lukaskabc Sep 3, 2024
4cf5fdd
fix exception handling
lukaskabc Sep 3, 2024
932506d
docs
lukaskabc Sep 3, 2024
fc978bc
update javadoc
lukaskabc Sep 3, 2024
62f3286
update javadoc
lukaskabc Sep 3, 2024
c47785c
add implSpec for exception handlers
lukaskabc Sep 3, 2024
6e86878
[Fix] Fix application not starting in OIDC mode due to wrong WebSocke…
ledsoft Sep 3, 2024
a300a10
move WS dependencies from security config
lukaskabc Sep 3, 2024
b357fe1
rework WebSocket configuration & authentication
lukaskabc Sep 3, 2024
355c4e2
TermitJwtDecoder
lukaskabc Sep 4, 2024
de338e8
fix JwtAuthenticationProvider and missing authorities
lukaskabc Sep 4, 2024
90fadb6
exception handling
lukaskabc Sep 4, 2024
cb22336
PR adjustments
lukaskabc Sep 4, 2024
09637f4
fix tests
lukaskabc Sep 4, 2024
f631e0e
fix principal resolving
lukaskabc Sep 4, 2024
79d4206
optimize imports
lukaskabc Sep 4, 2024
61dc2b9
optimize imports
lukaskabc Sep 4, 2024
0dde502
[Bug#293] Remove square brackets when generating identifier.
ledsoft Sep 9, 2024
cc82de9
[Ref] Add messageId to TermItException so that all exceptions can hav…
ledsoft Sep 9, 2024
e8ed3ac
[Bug #293] Add more general handling of identifier generation errors.
ledsoft Sep 9, 2024
ca71866
Revert "[HotFix] Allow disabling automatic text analysis of all vocab…
lukaskabc Aug 15, 2024
4969e2a
Debounce aspect
lukaskabc Aug 16, 2024
f397a02
Throttle aspect with spring aop
lukaskabc Aug 20, 2024
497cd7c
Throttle aspect & tests
lukaskabc Aug 21, 2024
94a4763
support for SpEL in groups
lukaskabc Aug 21, 2024
3b59545
explicitly handle transactions
lukaskabc Aug 22, 2024
28c0102
disable sync term saver
lukaskabc Aug 22, 2024
0539a67
async mvc
lukaskabc Aug 23, 2024
e87ad1f
occurrence saving in parallel
lukaskabc Aug 23, 2024
4aa4b70
fix tests
lukaskabc Aug 23, 2024
00dff87
use parallel occurrence saving only for files
lukaskabc Aug 26, 2024
5edbb6a
validation caching
lukaskabc Aug 27, 2024
99f0294
fix tests
lukaskabc Sep 3, 2024
5ec261f
suppress AsyncRequestNotUsableException from logging
lukaskabc Sep 4, 2024
498fd8b
merge
lukaskabc Sep 4, 2024
23293a8
optimize imports
lukaskabc Sep 4, 2024
347f000
validation cache
lukaskabc Sep 4, 2024
c81d347
[Performance #287] Sending messages to session, validation throttling
lukaskabc Sep 5, 2024
504add3
[Performance #287] Resolve invalid thread synchronization
lukaskabc Sep 5, 2024
36e0a7f
[Performance #287] Trigger validation on vocabulary modification even…
lukaskabc Sep 5, 2024
3a86e8b
[Performance #287] Introduce base class for Vocabulary related event
lukaskabc Sep 5, 2024
4b303a5
[Performance #287] Docs for throttle related classes
lukaskabc Sep 5, 2024
b93a36f
[Performance #287] Docs for throttle related classes, tests descripti…
lukaskabc Sep 6, 2024
f3074c4
[Performance #287] Adds async tests for ThrottledFuture running
lukaskabc Sep 6, 2024
bdd0c40
[Performance #287] test for calling web socket exception handler
lukaskabc Sep 9, 2024
cd2af1e
optimize imports
lukaskabc Sep 9, 2024
ebf4c36
[Performance #287] remove async mvc
lukaskabc Sep 9, 2024
25aced4
[Performance #287] prevent concurrent execution of throttled tasks wi…
lukaskabc Sep 9, 2024
7a0509c
[Performance #287] adds tests for throttled future
lukaskabc Sep 9, 2024
cdfb71d
[Performance #287] remove vocabulary content modified event on vocabu…
lukaskabc Sep 9, 2024
21e88d3
[Performance #285] publishing text analysis to websocket
lukaskabc Sep 9, 2024
bab3bef
[Performance #285] fix text analysis tests
lukaskabc Sep 10, 2024
12a69c9
[Performance #285] remove trace time logging and improve throttled fu…
lukaskabc Sep 10, 2024
9e32122
[Performance #285] rename term service tests for better description
lukaskabc Sep 10, 2024
75e32dd
[Performance #285] remove unused class MockedFuture
lukaskabc Sep 10, 2024
41644ad
optimize imports
lukaskabc Sep 10, 2024
1e39d9f
code cleanup
lukaskabc Sep 10, 2024
1d40b8c
[Performance #285] Implement API for retrieval of long-running tasks …
lukaskabc Sep 10, 2024
c2f9bac
[Performance #285] Fix test error due to new controller missing depen…
lukaskabc Sep 11, 2024
b26f13e
[Performance #285] Sending current running tasks to a client on subsc…
lukaskabc Sep 11, 2024
6be374e
[Performance #285] add uuid to long running task status logging
lukaskabc Sep 11, 2024
16642b6
[Performance #285] change when notification about running task change…
lukaskabc Sep 11, 2024
13fe4da
[Performance #285] reset client when all long-running tasks completed
lukaskabc Sep 11, 2024
d428f1d
[Performance #285] add description for name in Throttle annotation
lukaskabc Sep 11, 2024
cb7c920
[Performance #285] remove entity re-fetch
lukaskabc Sep 11, 2024
e77b944
[Performance #285] notify about long-running task change on future ca…
lukaskabc Sep 11, 2024
929f8f3
[Performance #285] add comment to calling get on throttled future
lukaskabc Sep 11, 2024
0ec7d95
[Performance #285] remove unnecessary stubbing for removed method call
lukaskabc Sep 11, 2024
e8f2da3
[Performance #285] send long running tasks to client as whole map to …
lukaskabc Sep 12, 2024
cb61a2f
[Performance #285] remove string builders, refetch entities in thrott…
lukaskabc Sep 12, 2024
a7a23eb
[PR #295] rename vocabulary events and replace jetbrains annotations
lukaskabc Sep 12, 2024
d4e2676
[Performance #285] fix event ordering in long-running tasks registry
lukaskabc Sep 12, 2024
df23e79
[PR #295] make defensive copy instead of unmodifiable view
lukaskabc Sep 12, 2024
2d5cd83
[Performance #285] change long running task registry handling
lukaskabc Sep 12, 2024
979e865
[PR #295] rename validator method to reflect its purpose
lukaskabc Sep 12, 2024
f238fac
[Performance #285] fix exceptional future competition
lukaskabc Sep 12, 2024
dcc5dfb
[PR #295] rollback VocabularyController changes
lukaskabc Sep 12, 2024
6b06c22
[PR #295] merge SynchronousTermOccurrenceSaver with TermOccurrenceSav…
lukaskabc Sep 12, 2024
c396895
[Performance #285] fix faulty test and ensure that the task is null a…
lukaskabc Sep 12, 2024
1104c60
[PR #295] remove parallel stream
lukaskabc Sep 12, 2024
d8555ac
[PR #295] optimize imports
lukaskabc Sep 12, 2024
5c52b0f
[PR #295] add Javadoc and prevent useless lambda redefinition in loop
lukaskabc Sep 12, 2024
6c21f4e
[PR #295] revert unsuccessfully attempt to optimize memory usage, res…
lukaskabc Sep 12, 2024
f3b9d9a
[PR #295] move throttle constants to configuration
lukaskabc Sep 12, 2024
dd6aff5
[Fix] Minor transactional behavior fix.
ledsoft Sep 13, 2024
ff53cfc
[Enhancement kbss-cvut/termit-ui#505] Introduce support for parametri…
lukaskabc Sep 13, 2024
270dc1b
[Ref] Remove ConfigParam enum, use just constants.
ledsoft Sep 16, 2024
54f84f7
[Enhancement #298] Support configuring ASCII-only identifiers.
ledsoft Sep 16, 2024
b00e962
[Enhancement #298] Generate ASCII-only identifiers when configured to.
ledsoft Sep 16, 2024
7db4e19
[Ref #296] replace all jetbrains and spring NotNull/NonNull & Nullabl…
lukaskabc Sep 19, 2024
e2b6e56
[Bug kbss-cvut/termit-ui#511] Entity identifiers will be now validate…
lukaskabc Sep 16, 2024
41fbc75
[Ref] fix inline comment in WebSocketExceptionHandler
lukaskabc Sep 17, 2024
1526072
[Bug kbss-cvut/termit-ui#511] rename method in ExceptionUtils
lukaskabc Sep 19, 2024
a68b74d
Merge branch 'refs/heads/development' into lukaskabc/Refactoring-296
lukaskabc Sep 23, 2024
a90c249
Merge pull request #301 from lukaskabc/lukaskabc/Refactoring-296
ledsoft Sep 23, 2024
91d8f5f
[3.2.0] Bump version.
ledsoft Sep 23, 2024
2f45d88
Merge branch 'master' into development
ledsoft Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

FROM maven:3-eclipse-temurin-17 as build
FROM maven:3-eclipse-temurin-17 AS build

WORKDIR /termit

Expand All @@ -31,7 +31,7 @@ COPY src src

RUN mvn package -B -P graphdb,standalone -DskipTests=true

FROM eclipse-temurin:17-jdk-alpine as runtime
FROM eclipse-temurin:17-jdk-alpine AS runtime
COPY --from=build /termit/target/termit.jar termit.jar

EXPOSE 8080
Expand Down
37 changes: 31 additions & 6 deletions doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,35 @@ termit:

TermIt can operate in two authentication modes:

1. Internal authentication means
2. [Keycloak](https://www.keycloak.org/) -based
1. Internal authentication
2. OAuth2 based (e.g. [Keycloak](https://www.keycloak.org/))

By default, OAuth2 is disabled and internal authentication is used
To enable it, set termit security provider to `oidc`
and provide issuer-uri and jwk-set-uri.

**`application.yml` example:**
```yml
spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: http://keycloak.lan/realms/termit
jwk-set-uri: http://keycloak.lan/realms/termit/protocol/openid-connect/certs
termit:
security:
provider: "oidc"
```

**Environmental variables example:**
```
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI=http://keycloak.lan/realms/termit
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWKSETURI=http://keycloak.lan/realms/termit/protocol/openid-connect/certs
TERMIT_SECURITY_PROVIDER=oidc
```

TermIt will automatically configure its security accordingly
(it is using Spring's [`ConditionalOnProperty`](https://www.baeldung.com/spring-conditionalonproperty)).

By default, Keycloak is disabled (see `keycloak.enabled` in `application.yml`). To enable it, set `keycloak.enabled` to `true` and
provide additional required Keycloak parameters - see the [Keycloak Spring Boot integration docs](https://www.keycloak.org/docs/latest/securing_apps/#_spring_boot_adapter).
TermIt will automatically configure its security (it is using Spring's [`ConditionalOnProperty`](https://www.baeldung.com/spring-conditionalonproperty))
accordingly.
**Note that termit-ui needs to be configured for mathcing authentication mode.**
Binary file added doc/throttle-debounce.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 17 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
</parent>

<artifactId>termit</artifactId>
<version>3.1.3</version>
<version>3.2.0</version>
<name>TermIt</name>
<description>Terminology manager based on Semantic Web technologies.</description>
<packaging>${packaging}</packaging>
Expand All @@ -29,10 +29,10 @@
<properties>
<java.version>17</java.version>
<org.apache.tika.tika-core.version>2.7.0</org.apache.tika.tika-core.version>
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
<org.springdoc.version>2.2.0</org.springdoc.version>
<cz.cvut.kbss.jopa.version>2.0.2</cz.cvut.kbss.jopa.version>
<cz.cvut.kbss.jsonld.version>0.14.3</cz.cvut.kbss.jsonld.version>
<org.mapstruct.version>1.6.0</org.mapstruct.version>
<org.springdoc.version>2.6.0</org.springdoc.version>
<cz.cvut.kbss.jopa.version>2.0.5</cz.cvut.kbss.jopa.version>
<cz.cvut.kbss.jsonld.version>0.15.0</cz.cvut.kbss.jsonld.version>

<!-- Default value for deployment type property which should otherwise specified on command line -->
<deployment>DEV</deployment>
Expand Down Expand Up @@ -112,7 +112,7 @@
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-rio-rdfxml</artifactId>
<version>5.0.0</version>
<version>5.0.2</version>
</dependency>

<!-- Spring declarative transactions with JOPA -->
Expand Down Expand Up @@ -149,6 +149,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-messaging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
Expand Down Expand Up @@ -286,7 +294,7 @@
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-spring-boot-starter</artifactId>
<version>2.0.0</version>
<version>2.2.0</version>
</dependency>

<!-- Caching -->
Expand Down Expand Up @@ -564,6 +572,7 @@
<goal>copy-resources</goal>
</goals>
<configuration>
<propertiesEncoding>ISO-8859-1</propertiesEncoding>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
</nonFilteredFileExtensions>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/cz/cvut/kbss/termit/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@

import cz.cvut.kbss.termit.util.AsyncExceptionHandler;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.aspectj.EnableSpringConfigured;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

@Configuration
@EnableMBeanExport
Expand All @@ -35,10 +38,24 @@
@EnableAsync
@EnableScheduling
@EnableRetry
@ImportResource("classpath*:spring-aop.xml")
public class AppConfig implements AsyncConfigurer {

@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return new AsyncExceptionHandler();
}

/**
* This thread pool is responsible for executing long-running tasks in the application.
*/
@Bean(destroyMethod = "destroy")
public ThreadPoolTaskScheduler longRunningTaskScheduler(cz.cvut.kbss.termit.util.Configuration config) {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(config.getAsyncThreadCount());
threadPoolTaskScheduler.setThreadNamePrefix("TermItScheduler-");
threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(true);
threadPoolTaskScheduler.setRemoveOnCancelPolicy(true);
return threadPoolTaskScheduler;
}
}
13 changes: 13 additions & 0 deletions src/main/java/cz/cvut/kbss/termit/config/OAuth2SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.session.SessionRegistryImpl;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
Expand Down Expand Up @@ -84,6 +86,17 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.build();
}

/**
* Supplies auth provider which is not exposed by HttpSecurity
* @see cz.cvut.kbss.termit.security.WebSocketJwtAuthorizationInterceptor
*/
@Bean
public JwtAuthenticationProvider jwtAuthenticationProvider(JwtDecoder jwtDecoder) {
final JwtAuthenticationProvider provider = new JwtAuthenticationProvider(jwtDecoder);
provider.setJwtAuthenticationConverter(grantedAuthoritiesExtractor());
return provider;
}

private CorsConfigurationSource corsConfigurationSource() {
return SecurityConfig.createCorsConfiguration(config.getCors());
}
Expand Down
30 changes: 28 additions & 2 deletions src/main/java/cz/cvut/kbss/termit/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import cz.cvut.kbss.termit.security.JwtAuthorizationFilter;
import cz.cvut.kbss.termit.security.JwtUtils;
import cz.cvut.kbss.termit.security.SecurityConstants;
import cz.cvut.kbss.termit.security.TermitJwtDecoder;
import cz.cvut.kbss.termit.service.security.TermItUserDetailsService;
import cz.cvut.kbss.termit.util.Constants;
import org.slf4j.Logger;
Expand All @@ -40,6 +41,10 @@
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider;
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
Expand Down Expand Up @@ -90,7 +95,7 @@ public SecurityConfig(AuthenticationProvider authenticationProvider,
}

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
public SecurityFilterChain filterChain(HttpSecurity http, TermitJwtDecoder jwtDecoder) throws Exception {
LOG.debug("Using internal security mechanisms.");
final AuthenticationManager authManager = buildAuthenticationManager(http);
http.authorizeHttpRequests((auth) -> auth.requestMatchers(antMatcher("/rest/query")).permitAll()
Expand All @@ -102,7 +107,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.logoutSuccessHandler(authenticationSuccessHandler))
.authenticationManager(authManager)
.addFilter(authenticationFilter(authManager))
.addFilter(new JwtAuthorizationFilter(authManager, jwtUtils, userDetailsService, objectMapper));
.addFilter(new JwtAuthorizationFilter(authManager, jwtUtils, objectMapper, jwtDecoder));
return http.build();
}

Expand All @@ -121,6 +126,22 @@ private JwtAuthenticationFilter authenticationFilter(AuthenticationManager authe
return authenticationFilter;
}

/**
* @see cz.cvut.kbss.termit.security.WebSocketJwtAuthorizationInterceptor
*/
@Bean
public JwtAuthenticationProvider jwtAuthenticationProvider(JwtDecoder jwtDecoder) {
final JwtGrantedAuthoritiesConverter authoritiesConverter = new JwtGrantedAuthoritiesConverter();
authoritiesConverter.setAuthorityPrefix(""); // this removes default "SCOPE_" prefix
// otherwise, all granted authorities would have this prefix
// (like "SCOPE_ROLE_RESTRICTED_USER", we want just ROLE_...)
final JwtAuthenticationConverter converter = new JwtAuthenticationConverter();
converter.setJwtGrantedAuthoritiesConverter(authoritiesConverter);
final JwtAuthenticationProvider provider = new JwtAuthenticationProvider(jwtDecoder);
provider.setJwtAuthenticationConverter(converter);
return provider;
}

private CorsConfigurationSource corsConfigurationSource() {
return createCorsConfiguration(config.getCors());
}
Expand All @@ -143,4 +164,9 @@ protected static CorsConfigurationSource createCorsConfiguration(
source.registerCorsConfiguration("/**", corsConfiguration);
return source;
}

@Bean
public TermitJwtDecoder jwtDecoder() {
return new TermitJwtDecoder(jwtUtils, userDetailsService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
package cz.cvut.kbss.termit.config;

import cz.cvut.kbss.termit.security.SecurityConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jakarta.servlet.annotation.WebListener;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@WebListener
public class SessionTimeoutManager implements HttpSessionListener {
Expand Down
45 changes: 24 additions & 21 deletions src/main/java/cz/cvut/kbss/termit/config/WebAppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import cz.cvut.kbss.jsonld.jackson.serialization.SerializationConstants;
import cz.cvut.kbss.termit.rest.servlet.DiagnosticsContextFilter;
import cz.cvut.kbss.termit.util.AdjustedUriTemplateProxyServlet;
import cz.cvut.kbss.termit.util.ConfigParam;
import cz.cvut.kbss.termit.util.Constants;
import cz.cvut.kbss.termit.util.json.MultilingualStringDeserializer;
import cz.cvut.kbss.termit.util.json.MultilingualStringSerializer;
Expand Down Expand Up @@ -62,19 +61,13 @@
@Configuration
public class WebAppConfig implements WebMvcConfigurer {

private final cz.cvut.kbss.termit.util.Configuration.Repository config;
private final cz.cvut.kbss.termit.util.Configuration config;

@Value("${application.version:development}")
private String version;

public WebAppConfig(cz.cvut.kbss.termit.util.Configuration config) {
this.config = config.getRepository();
}

@Bean(name = "objectMapper")
@Primary
public ObjectMapper objectMapper() {
return createJsonObjectMapper();
this.config = config;
}

/**
Expand All @@ -99,11 +92,6 @@ public static ObjectMapper createJsonObjectMapper() {
return objectMapper;
}

@Bean(name = "jsonLdMapper")
public ObjectMapper jsonLdObjectMapper() {
return createJsonLdObjectMapper();
}

/**
* Creates an {@link ObjectMapper} for processing JSON-LD using the JB4JSON-LD library.
* <p>
Expand All @@ -119,9 +107,21 @@ public static ObjectMapper createJsonLdObjectMapper() {
jsonLdModule.configure(cz.cvut.kbss.jsonld.ConfigParam.SCAN_PACKAGE, "cz.cvut.kbss.termit");
jsonLdModule.configure(SerializationConstants.FORM, SerializationConstants.FORM_COMPACT_WITH_CONTEXT);
mapper.registerModule(jsonLdModule);
mapper.registerModule(new JavaTimeModule());
return mapper;
}

@Bean(name = "objectMapper")
@Primary
public ObjectMapper objectMapper() {
return createJsonObjectMapper();
}

@Bean(name = "jsonLdMapper")
public ObjectMapper jsonLdObjectMapper() {
return createJsonLdObjectMapper();
}

/**
* Register the proxy for SPARQL endpoint.
*
Expand All @@ -133,10 +133,13 @@ public ServletWrappingController sparqlEndpointController() throws Exception {
controller.setServletClass(AdjustedUriTemplateProxyServlet.class);
controller.setBeanName("sparqlEndpointProxyServlet");
final Properties p = new Properties();
p.setProperty("targetUri", config.getUrl());
final cz.cvut.kbss.termit.util.Configuration.Repository repository = config.getRepository();
p.setProperty("targetUri", repository.getUrl());
p.setProperty("log", "false");
p.setProperty(ConfigParam.REPO_USERNAME.toString(), config.getUsername() != null ? config.getUsername() : "");
p.setProperty(ConfigParam.REPO_PASSWORD.toString(), config.getPassword() != null ? config.getPassword() : "");
p.setProperty(AdjustedUriTemplateProxyServlet.REPO_USERNAME_PARAM,
repository.getUsername() != null ? repository.getUsername() : "");
p.setProperty(AdjustedUriTemplateProxyServlet.REPO_PASSWORD_PARAM,
repository.getPassword() != null ? repository.getPassword() : "");
controller.setInitParameters(p);
controller.afterPropertiesSet();
return controller;
Expand All @@ -153,27 +156,27 @@ public SimpleUrlHandlerMapping sparqlQueryControllerMapping() throws Exception {
}

@Bean
public HttpMessageConverter<?> stringMessageConverter() {
public HttpMessageConverter<?> termitStringHttpMessageConverter() {
return new StringHttpMessageConverter(StandardCharsets.UTF_8);
}

@Bean
public HttpMessageConverter<?> jsonLdMessageConverter() {
public HttpMessageConverter<?> termitJsonLdHttpMessageConverter() {
final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(
jsonLdObjectMapper());
converter.setSupportedMediaTypes(Collections.singletonList(MediaType.valueOf(JsonLd.MEDIA_TYPE)));
return converter;
}

@Bean
public HttpMessageConverter<?> jsonMessageConverter() {
public HttpMessageConverter<?> termitJsonHttpMessageConverter() {
final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(objectMapper());
return converter;
}

@Bean
public HttpMessageConverter<?> resourceMessageConverter() {
public HttpMessageConverter<?> termitResourceHttpMessageConverter() {
return new ResourceHttpMessageConverter();
}

Expand Down
Loading