TSK-1520: introduced taskana-common-security as a dedicated module.
This commit is contained in:
parent
67fcfbf9db
commit
e87de29761
|
|
@ -218,6 +218,7 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
module:
|
module:
|
||||||
- taskana-common
|
- taskana-common
|
||||||
|
- taskana-common-security
|
||||||
- taskana-common-data
|
- taskana-common-data
|
||||||
- taskana-common-test
|
- taskana-common-test
|
||||||
- taskana-core
|
- taskana-core
|
||||||
|
|
@ -347,7 +348,7 @@ jobs:
|
||||||
./mvnw -B deploy -P $([[ "$GITHUB_REF" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "release" || echo "snapshot") \
|
./mvnw -B deploy -P $([[ "$GITHUB_REF" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "release" || echo "snapshot") \
|
||||||
--settings ci/mvnsettings.xml -DskipTests -Dcheckstyle.skip -Dasciidoctor.skip -Djacoco.skip \
|
--settings ci/mvnsettings.xml -DskipTests -Dcheckstyle.skip -Dasciidoctor.skip -Djacoco.skip \
|
||||||
-pl :taskana-parent,\
|
-pl :taskana-parent,\
|
||||||
:taskana-common-parent,:taskana-common,:taskana-common-data,:taskana-common-test,\
|
:taskana-common-parent,:taskana-common,:taskana-common-security,:taskana-common-data,:taskana-common-test,\
|
||||||
:taskana-lib-parent,:taskana-core,:taskana-cdi,:taskana-spring,\
|
:taskana-lib-parent,:taskana-core,:taskana-cdi,:taskana-spring,\
|
||||||
:taskana-rest-parent,:taskana-web,:taskana-rest-spring,\
|
:taskana-rest-parent,:taskana-web,:taskana-rest-spring,\
|
||||||
:taskana-history-parent,:taskana-simplehistory-provider,:taskana-simplehistory-rest-spring,:taskana-loghistory-provider
|
:taskana-history-parent,:taskana-simplehistory-provider,:taskana-simplehistory-rest-spring,:taskana-loghistory-provider
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>taskana-common</module>
|
<module>taskana-common</module>
|
||||||
|
<module>taskana-common-security</module>
|
||||||
<module>taskana-common-data</module>
|
<module>taskana-common-data</module>
|
||||||
<module>taskana-common-test</module>
|
<module>taskana-common-test</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>taskana-common-security</artifactId>
|
||||||
|
|
||||||
|
<name>${project.groupId}:${project.artifactId}</name>
|
||||||
|
<description>The global security principals needed for user and group authentication</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>taskana-common-parent</artifactId>
|
||||||
|
<groupId>pro.taskana</groupId>
|
||||||
|
<version>4.3.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package pro.taskana.common.internal.security;
|
package pro.taskana.common.internal.security;
|
||||||
|
|
||||||
import static pro.taskana.common.internal.util.CheckedFunction.wrap;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
|
|
@ -87,12 +85,22 @@ public class CurrentUserContextImpl implements CurrentUserContext {
|
||||||
LOGGER.debug("Public credentials of caller: {}", publicCredentials);
|
LOGGER.debug("Public credentials of caller: {}", publicCredentials);
|
||||||
return publicCredentials.stream()
|
return publicCredentials.stream()
|
||||||
.map(
|
.map(
|
||||||
wrap(
|
// we could use CheckedFunction#wrap here, but this either requires a dependency
|
||||||
credential ->
|
// to taskana-common or an inclusion of the class CheckedFunction in this module.
|
||||||
credential
|
// The first is not possible due to a cyclic dependency.
|
||||||
.getClass()
|
// The second is not desired, since this module is a very slim security module and
|
||||||
.getMethod(GET_UNIQUE_SECURITY_NAME_METHOD, (Class<?>[]) null)
|
// the inclusion of CheckedFunction and its transitive dependencies would increase
|
||||||
.invoke(credential, (Object[]) null)))
|
// the module scope and introduce inconsistency.
|
||||||
|
credential -> {
|
||||||
|
try {
|
||||||
|
return credential
|
||||||
|
.getClass()
|
||||||
|
.getMethod(GET_UNIQUE_SECURITY_NAME_METHOD, (Class<?>[]) null)
|
||||||
|
.invoke(credential, (Object[]) null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new SecurityException("Could not retrieve principal", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
.peek(
|
.peek(
|
||||||
o ->
|
o ->
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
|
|
@ -15,6 +15,11 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>pro.taskana</groupId>
|
||||||
|
<artifactId>taskana-common-security</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue