Skip to content

Commit 7cf0359

Browse files
committed
Verify SAML responses using OpenSAML
1 parent 43377a4 commit 7cf0359

File tree

14 files changed

+386
-228
lines changed

14 files changed

+386
-228
lines changed

ModuleConfig.cfc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ component {
2020
this.entryPoint = "/cbsso";
2121

2222
// Dependencies
23-
this.dependencies = [ "hyper", "jwtcfml" ];
23+
this.dependencies = [ "hyper", "jwtcfml", "cbjavaloader" ];
2424

2525
routes = [
2626
{
@@ -52,7 +52,11 @@ component {
5252
// accessTokenEndpoint : "https://www.googleapis.com/oauth2/v4/token",
5353
// redirectUri : getSystemSetting( key = "GOOGLE_REDIRECT_URI", defaultValue = "" )
5454
// }
55-
]
55+
],
56+
cbjavaloader: {
57+
loadPaths: [ modulePath & "/lib" ],
58+
parentClassLoader: createObject("java", "java.lang.ClassLoader").getSystemClassLoader()
59+
}
5660
};
5761

5862
interceptorSettings = { customInterceptionPoints : [ "CBSSOMissingProvider", "CBSSOAuthorization" ] };

box.json

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,67 @@
11
{
2-
"name": "cbsso",
3-
"version": "1.0.0",
4-
"location": "https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbsso/@build.version@/[email protected]@.zip",
5-
"author": "Ortus Solutions <[email protected]>",
6-
"homepage": "https://github.com/coldbox-modules/cbsso",
7-
"documentation": "https://github.com/coldbox-modules/cbsso",
8-
"repository": {
9-
"type": "git",
10-
"url": "https://github.com/coldbox-modules/cbsso"
2+
"name":"cbsso",
3+
"version":"1.0.0",
4+
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbsso/@build.version@/[email protected]@.zip",
5+
"author":"Ortus Solutions <[email protected]>",
6+
"homepage":"https://github.com/coldbox-modules/cbsso",
7+
"documentation":"https://github.com/coldbox-modules/cbsso",
8+
"repository":{
9+
"type":"git",
10+
"url":"https://github.com/coldbox-modules/cbsso"
1111
},
12-
"bugs": "https://github.com/coldbox-modules/cbsso",
13-
"shortDescription": "Description goes here",
14-
"slug": "cbsso",
15-
"type": "modules",
16-
"keywords": "",
17-
"license": [
12+
"bugs":"https://github.com/coldbox-modules/cbsso",
13+
"shortDescription":"Description goes here",
14+
"slug":"cbsso",
15+
"type":"modules",
16+
"keywords":"",
17+
"license":[
1818
{
19-
"type": "Apache2",
20-
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
19+
"type":"Apache2",
20+
"url":"http://www.apache.org/licenses/LICENSE-2.0.html"
2121
}
2222
],
23-
"contributors": [ ],
24-
"dependencies": {
25-
"hyper": "^7.2.1",
26-
"jwt-cfml": "^1.2.0"
23+
"contributors":[],
24+
"dependencies":{
25+
"hyper":"^7.2.1",
26+
"jwt-cfml":"^1.2.0",
27+
"cbjavaloader":"^2.1.1+8"
2728
},
28-
"devDependencies": {
29-
"commandbox-cfformat": "*",
30-
"commandbox-docbox": "*",
31-
"commandbox-dotenv": "*",
32-
"commandbox-cfconfig": "*"
29+
"devDependencies":{
30+
"commandbox-cfformat":"*",
31+
"commandbox-docbox":"*",
32+
"commandbox-dotenv":"*",
33+
"commandbox-cfconfig":"*"
3334
},
34-
"ignore": [
35+
"ignore":[
3536
"**/.*",
3637
"test-harness",
3738
"/server*.json"
3839
],
39-
"scripts": {
40-
"setupTemplate": "task run taskFile=build/SetupTemplate.cfc",
41-
"build:module": "task run taskFile=build/Build.cfc :projectName=`package show slug` :version=`package show version`",
42-
"build:docs": "task run taskFile=build/Build.cfc target=docs :projectName=`package show slug` :version=`package show version`",
43-
"install:dependencies": "install && cd test-harness && install",
44-
"release": "recipe build/release.boxr",
45-
"format": "cfformat run helpers,models,test-harness/tests/,ModuleConfig.cfc --overwrite",
46-
"format:watch": "cfformat watch helpers,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json",
47-
"format:check": "cfformat check helpers,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json",
48-
"start:lucee": "server start [email protected]",
49-
"start:2018": "server start [email protected]",
50-
"start:2021": "server start [email protected]",
51-
"stop:lucee": "server stop [email protected]",
52-
"stop:2018": "server stop [email protected]",
53-
"stop:2021": "server stop [email protected]",
54-
"logs:lucee": "server log [email protected] --follow",
55-
"logs:2018": "server log [email protected] --follow",
56-
"logs:2021": "server log [email protected] --follow"
40+
"scripts":{
41+
"setupTemplate":"task run taskFile=build/SetupTemplate.cfc",
42+
"build:module":"task run taskFile=build/Build.cfc :projectName=`package show slug` :version=`package show version`",
43+
"build:docs":"task run taskFile=build/Build.cfc target=docs :projectName=`package show slug` :version=`package show version`",
44+
"install:dependencies":"install && cd test-harness && install",
45+
"release":"recipe build/release.boxr",
46+
"format":"cfformat run helpers,models,test-harness/tests/,ModuleConfig.cfc --overwrite",
47+
"format:watch":"cfformat watch helpers,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json",
48+
"format:check":"cfformat check helpers,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json",
49+
"start:lucee":"server start [email protected]",
50+
"start:2018":"server start [email protected]",
51+
"start:2021":"server start [email protected]",
52+
"stop:lucee":"server stop [email protected]",
53+
"stop:2018":"server stop [email protected]",
54+
"stop:2021":"server stop [email protected]",
55+
"logs:lucee":"server log [email protected] --follow",
56+
"logs:2018":"server log [email protected] --follow",
57+
"logs:2021":"server log [email protected] --follow"
5758
},
58-
"testbox": {
59-
"runner": "http://localhost:60299/tests/runner.cfm"
59+
"testbox":{
60+
"runner":"http://localhost:60299/tests/runner.cfm"
6061
},
61-
"installPaths": {
62-
"hyper": "modules/hyper/",
63-
"jwt-cfml": "modules/jwtcfml/"
62+
"installPaths":{
63+
"hyper":"modules/hyper/",
64+
"jwt-cfml":"modules/jwtcfml/",
65+
"cbjavaloader":"modules/cbjavaloader/"
6466
}
6567
}

java/cbsso-opensaml/app/build.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@
88
plugins {
99
// Apply the application plugin to add support for building a CLI application in Java.
1010
id 'application'
11+
12+
id 'com.github.johnrengelman.shadow' version '8.1.1'
1113
}
1214

15+
sourceCompatibility = 11
16+
targetCompatibility = 11
17+
1318
repositories {
1419
// Use Maven Central for resolving dependencies.
1520
mavenCentral()
@@ -48,6 +53,25 @@ application {
4853
mainClass = 'cbsso.opensaml.App'
4954
}
5055

56+
jar {
57+
archiveBaseName = "cbsso-opensaml"
58+
}
59+
60+
shadowJar {
61+
archiveBaseName = "cbsso-opensaml"
62+
mergeServiceFiles()
63+
minimize{
64+
exclude( dependency( "org.opensaml:opensaml-core:.*" ) )
65+
exclude( dependency( "org.slf4j:.*:.*" ) )
66+
exclude( dependency( "org.opensaml:opensaml-saml-impl:.*" ) )
67+
exclude( dependency( "org.opensaml:opensaml-soap-api:.*" ) )
68+
exclude( dependency( "org.opensaml:opensaml-xmlsec-api:.*" ) )
69+
exclude( dependency( "org.opensaml:opensaml-security-api:.*" ) )
70+
exclude( dependency( "org.opensaml:opensaml-security-impl:.*" ) )
71+
exclude( dependency( "org.opensaml:opensaml-profile-api:.*" ) )
72+
}
73+
}
74+
5175
tasks.named('test') {
5276
// Use JUnit Platform for unit tests.
5377
useJUnitPlatform()

java/cbsso-opensaml/app/src/main/java/cbsso/opensaml/App.java

Lines changed: 0 additions & 111 deletions
This file was deleted.

java/cbsso-opensaml/app/src/main/java/cbsso/opensaml/AuthNRequestGenerator.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,27 @@
1818
import net.shibboleth.utilities.java.support.xml.ParserPool;
1919

2020
public class AuthNRequestGenerator {
21+
22+
private static boolean initialized = false;
23+
2124
public static String generateAuthNRequest(String issuerId, String requestId)
2225
throws InitializationException, ComponentInitializationException {
23-
initOpenSAML();
26+
// initOpenSAML();
2427
AuthnRequest authnRequest = buildAuthnRequest(issuerId, requestId);
2528
return OpenSAMLUtils.stringifySAMLObject(authnRequest);
2629
}
2730

28-
private static void initOpenSAML() throws InitializationException, ComponentInitializationException {
31+
public synchronized static void initOpenSAML() throws InitializationException, ComponentInitializationException {
32+
if (initialized) {
33+
return;
34+
}
2935
XMLObjectProviderRegistry registry = new XMLObjectProviderRegistry();
3036
ConfigurationService.register(XMLObjectProviderRegistry.class, registry);
3137

3238
registry.setParserPool(getParserPool());
3339
InitializationService.initialize();
40+
41+
initialized = true;
3442
}
3543

3644
private static ParserPool getParserPool() throws ComponentInitializationException {

0 commit comments

Comments
 (0)