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

feat(jans-keycloak-integration): enhancements to keycloak integration #8614 #8747

Merged
merged 40 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ffe3dbe
fix(jans-linux-setup): improper scim configuration for jans kc #8210
uprightech Apr 3, 2024
76e0414
Merge remote-tracking branch 'origin/main'
uprightech Apr 8, 2024
97f3c02
Merge remote-tracking branch 'origin/main'
uprightech Apr 16, 2024
fadf1f2
chore(jans-keycloak-integration): bump kc version to 24.0.0 #8315
uprightech Apr 16, 2024
8bde8d5
feat(jans-keycloak-integration): keycloak protocol mapper
uprightech Apr 30, 2024
91021f8
Merge remote-tracking branch 'origin/main' into protocol-mapper
uprightech Apr 30, 2024
0273af8
feat(jans-keycloak-integration): remove references to jans standalone…
uprightech May 1, 2024
c021a22
Merge remote-tracking branch 'origin/main' into protocol-mapper
uprightech May 6, 2024
10a0162
feat(jans-keycloak-integration): experimental protocol mapper for kc …
uprightech May 30, 2024
0f1c5a4
feat(jans-keycloak-integration): added dependencies for protocol mapp…
uprightech May 30, 2024
a089c83
feat(jans-keycloak-integration): experimental protocol mapper #8614
uprightech May 30, 2024
aa6e65d
feat(jans-keycloak-integration): experimental protocol mapper #8614
uprightech May 30, 2024
6e6e085
feat(jans-keycloak-integration): janssen spi bundle #8614
uprightech May 31, 2024
c006ad2
feat(jans-keycloak-integration): janssen spi bundle #8614
uprightech May 31, 2024
6e99863
feat(jans-keycloak-integration): enhancements to job-scheduler #8614
uprightech Jun 18, 2024
2367adb
feat(jans-keycloak-integration): keycloak integration enhancements #…
uprightech Jun 18, 2024
a839e12
feat(jans-keycloak-integration): spi bundle #8614
uprightech Jun 18, 2024
79d3255
feat(jans-keycloak-integration): keycloak integration enhancements #8614
uprightech Jun 18, 2024
76e79f3
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
4f453ab
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
abf22ed
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
a67f977
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
7e4567e
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
7ec45bd
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
88eac7f
Merge remote-tracking branch 'origin/main' into issue_8614
uprightech Jun 18, 2024
086808d
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
f444ea1
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
92ee6d2
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
f25ff29
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 18, 2024
a84d52a
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 19, 2024
b4459c1
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 19, 2024
78920ff
Merge remote-tracking branch 'origin/main' into issue_8614
uprightech Jun 20, 2024
db62d0f
feat(jans-keycloak-integration): enhancement to jans-keycloak-integra…
uprightech Jun 20, 2024
c405477
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 20, 2024
0870995
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 24, 2024
64575c7
Merge remote-tracking branch 'origin/main' into issue_8614
uprightech Jun 24, 2024
b571739
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 24, 2024
1a1de0f
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 24, 2024
f609351
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 24, 2024
d5f9221
feat(jans-keycloak-integration): enhancements to jans-keycloak-integr…
uprightech Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ private void initClientRepresentation() {
clientRepresentation.setAuthenticationFlowBindingOverrides(authnFlowBindingOverrides);

//set default saml attributes
samlShoulDocumentsBeSigned(false);
samlSignAssertions(false);
samlShoulDocumentsBeSigned(true);
samlSignAssertions(true);
samlForcePostBinding(false);
samlEncryptAssertions(false);
samlForceArtifactBinding(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ public SamlUserAttributeMapperBuilder attributeNameFormatUnspecified() {
return this;
}

public SamlUserAttributeMapperBuilder jansAttributeName(final String attributename) {

config.put("jans.attribute.name",attributename);
return this;
}

public ProtocolMapper build() {

return this.mapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,21 @@ public static void main(String[] args) throws InterruptedException, ParserCreate
Thread.sleep(1000);
}
}
log.info("Application shutthing down");
log.info("Application shutting down");
}catch(StartupError e) {
log.error("Application startup failed",e);
if(jobScheduler != null) {
jobScheduler.stop();
}
System.exit(-1);
return;
}catch(Exception e) {
log.error("Fatal error starting application",e);
if(jobScheduler != null ) {
jobScheduler.stop();
}
System.exit(-1);
return;
}

}
Expand Down Expand Up @@ -163,10 +170,8 @@ private static final JobScheduler createQuartzJobSchedulerFromConfiguration(AppC

private static final void runCronJobs() {

log.debug("Running trust relationship sync cron job");
TrustRelationshipSyncJob trsyncjob = new TrustRelationshipSyncJob();
trsyncjob.run(null);
log.debug("Trust relationship sync cron job complete");
}

private static final void performPostStartupOperations() {
Expand Down Expand Up @@ -271,7 +276,7 @@ public static class ShutdownHook extends Thread {
public void run() {

try {
log.debug("Shutting down application");
log.info("Shutting down application");
if (jobScheduler != null) {
jobScheduler.stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ public TrustRelationshipSyncJob() {
this.keycloakApi = App.keycloakApi();
this.realm = App.configuration().keycloakResourcesRealm();
this.samlUserAttributeMapperId = App.configuration().keycloakResourcesSamlUserAttributeMapper();
try {
this.authnBrowserFlow = keycloakApi.getAuthenticationFlowFromAlias(realm,App.configuration().keycloakResourcesBrowserFlowAlias());
}catch(Exception e) {
log.warn("Could not properly initialize sync job",e);
this.authnBrowserFlow = null;
}
this.authnBrowserFlow = keycloakApi.getAuthenticationFlowFromAlias(realm,App.configuration().keycloakResourcesBrowserFlowAlias());
}

@Override
Expand Down Expand Up @@ -212,14 +207,19 @@ private void addReleasedAttributesToManagedSamlClient(ManagedSamlClient client,

List<ProtocolMapper> protmappers = releasedattributes.stream().map((r)-> {
log.debug("Preparing to add released attribute {} to managed saml client with clientId {}",r.getName(),client.clientId());
return ProtocolMapper
/*return ProtocolMapper
.samlUserAttributeMapper(samlUserAttributeMapperId)
.name(generateKeycloakUniqueProtocolMapperName(r))
.userAttribute(r.getName())
.friendlyName(r.getDisplayName()!=null?r.getDisplayName():r.getName())
.attributeName(r.getSaml2Uri())
.attributeNameFormatUriReference()
.build();
.build(); */
return ProtocolMapper
.samlUserAttributeMapper(samlUserAttributeMapperId)
.name(generateKeycloakUniqueProtocolMapperName(r))
.jansAttributeName(r.getName())
.build();
}).toList();

keycloakApi.addProtocolMappersToManagedSamlClient(realm, client, protmappers);
Expand All @@ -228,12 +228,16 @@ private void addReleasedAttributesToManagedSamlClient(ManagedSamlClient client,
private void updateManagedSamlClientProtocolMapper(ManagedSamlClient client, ProtocolMapper mapper, JansAttributeRepresentation releasedattribute) {

log.debug("Updating managed client released attribute. Client id: {} / Attribute name: {}",client.clientId(),releasedattribute.getName());
ProtocolMapper newmapper = ProtocolMapper
/*ProtocolMapper newmapper = ProtocolMapper
.samlUserAttributeMapper(mapper)
.userAttribute(releasedattribute.getName())
.friendlyName(releasedattribute.getDisplayName()!=null?releasedattribute.getDisplayName():releasedattribute.getName())
.attributeName(releasedattribute.getSaml2Uri())
.attributeNameFormatUriReference()
.build(); */
ProtocolMapper newmapper = ProtocolMapper
.samlUserAttributeMapper(mapper)
.jansAttributeName(releasedattribute.getName())
.build();
keycloakApi.updateManagedSamlClientProtocolMapper(realm, client,newmapper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
ExecutionContext effectivecontext = new QuartzExecutionContext(context.getMergedJobDataMap());
job.run(effectivecontext);
} catch(ReflectiveOperationException e) {
e.printStackTrace();
throw new JobExecutionException("Failed to run job " + jobname,e);
}catch(Exception e) {
throw new JobExecutionException("Failed to run job " + jobname,e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ app.job.trustrelationship-sync.schedule-interval=PT10M
# keycloak resources configuration
app.keycloak.resources.realm=jans
app.keycloak.resources.authn.browser.flow-alias=janssen login
app.keycloak.resources.saml.user-attribute-mapper=saml-user-attribute-mapper
app.keycloak.resources.saml.user-attribute-mapper=kc-jans-saml-user-attribute-mapper
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<File>${app.logdir}/scheduler.log</File>
<append>true</append>
<rollingPolicy class="TimeBasedRollingPolicy">
<fileNamePattern>${app.logdir}/scheduler-%d{yyyy-mm-dd}.log.gz</fileNamePattern>
<fileNamePattern>${app.logdir}/scheduler-%d{yyyy-MM-dd}.log.gz</fileNamePattern>
<maxHistory>${app.logging.loghistory:-180}</maxHistory>
</rollingPolicy>

Expand Down
66 changes: 54 additions & 12 deletions jans-keycloak-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<module>authenticator</module>
<module>storage-spi</module>
<module>job-scheduler</module>
<module>spi</module>
</modules>

<repositories>
Expand Down Expand Up @@ -144,14 +145,6 @@
</dependency>
<!-- end nimbus dependencies-->

<!-- janssen dependencies -->
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-scim-model</artifactId>
<version>${jans.version}</version>
</dependency>
<!-- end janssen dependencies-->

<!-- jakarta dependencies -->
<dependency>
<groupId>jakarta.ws.rs</groupId>
Expand Down Expand Up @@ -282,7 +275,55 @@
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-saml</artifactId>
<version>${project.version}</version>
<version>${jans.version}</version>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-scim-model</artifactId>
<version>${jans.version}</version>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-standalone</artifactId>
<version>${jans.version}</version>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-standalone</artifactId>
<version>${jans.version}</version>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-couchbase</artifactId>
<version>${jans.version}</version>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-hybrid</artifactId>
<version>${jans.version}</version>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-ldap</artifactId>
<version>${jans.version}</version>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-sql</artifactId>
<version>${jans.version}</version>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-service</artifactId>
<version>${jans.version}</version>
</dependency>
<!-- end jans dependencies -->
</dependencies>
Expand Down Expand Up @@ -335,14 +376,15 @@
com.fasterxml.jackson.core,
commons-codec,
commons-lang3,
commons-lang,
commons-collections4,
commons-io,
commons-logging,
commons-text,
org.apache.commons,
commons-configuration
jakarta.persistence
</excludeGroupIds>
<excludeArtifactIds>

</excludeArtifactIds>
</configuration>
</execution>
</executions>
Expand Down
124 changes: 124 additions & 0 deletions jans-keycloak-integration/protocol-mapper/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>io.jans</groupId>
<artifactId>kc-jans-protocol-mapper</artifactId>
<name>kc-jans-protocol-mapper</name>
<packaging>jar</packaging>

<parent>
<groupId>io.jans</groupId>
<artifactId>jans-kc-parent</artifactId>
<version>1.1.2-SNAPSHOT</version>
</parent>

<prerequisites>
<maven>${maven.min-version}</maven>
</prerequisites>

<dependencies>

<!-- keycloak dependencies -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi</artifactId>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi-private</artifactId>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-services</artifactId>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-core-public</artifactId>
</dependency>
<!-- end keycloak dependencies-->

<!-- jans dependencies -->
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-standalone</artifactId>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-service</artifactId>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-standalone</artifactId>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-couchbase</artifactId>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-hybrid</artifactId>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-ldap</artifactId>
</dependency>

<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-sql</artifactId>
</dependency>
<!-- end jans dependencies -->

<!-- log adapter -->
<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logmanager</artifactId>
<version>2.0.1.Final</version>
</dependency>
<!-- log adapter -->

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.12.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<!-- maven deps plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<!-- end maven deps plugin-->

<!-- maven assembly plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<!-- end maven assembly plugin -->

<!-- maven compiler plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- end maven compiler plugin -->
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
<id>deps</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>target/deps/</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/resources/assembly</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>*.DONOTDELETE</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Loading