Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dariah
dariahsp
Commits
2066778e
Commit
2066778e
authored
Oct 29, 2020
by
Gradl, Tobias
Browse files
2: Migrate core behavior to new base
Task-Url:
#2
parent
94414864
Pipeline
#17511
passed with stage
in 1 minute and 44 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
dariahsp-sample/src/main/java/eu/dariah/de/dariahsp/sample/config/SamlProperties.java
View file @
2066778e
package
eu.dariah.de.dariahsp.sample.config
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.opensaml.saml.common.xml.SAMLConstants
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -28,15 +31,31 @@ public class SamlProperties {
@Getter
@Setter
public
class
SpProperties
{
private
String
externalMetadata
;
private
I
nt
eger
maxAuthAge
;
private
i
nt
maxAuthAge
=
3600
;
private
String
entityId
;
private
int
httpClientTimoutMs
=
2000
;
private
boolean
signMetadata
;
private
String
signingAlgorithm
;
private
boolean
requireArtifactResolveSigned
;
private
boolean
requireLogoutRequestSigned
;
private
boolean
requireLogoutResponseSigned
;
private
List
<
String
>
allowedNameIds
;
private
List
<
String
>
signingMethods
;
private
List
<
String
>
digestMethods
;
private
List
<
String
>
supportedProtocols
;
private
boolean
authnRequestSigned
=
true
;
private
boolean
logoutRequestSigned
=
false
;
private
boolean
wantsAssertionsSigned
=
true
;
private
boolean
wantsResponsesSigned
=
true
;
private
List
<
ConditionalAttributeSet
>
requiredAttributes
;
// ------------------------------------------
// Custom getters for complex default values
// ------------------------------------------
public
List
<
String
>
getSupportedProtocols
()
{
List
<
String
>
p
=
supportedProtocols
;
if
(
p
==
null
)
{
p
=
new
ArrayList
<>();
p
.
add
(
SAMLConstants
.
SAML20_NS
);
}
return
p
;
}
}
}
\ No newline at end of file
dariahsp-sample/src/main/java/eu/dariah/de/dariahsp/sample/config/SecurityConfig.java
View file @
2066778e
...
...
@@ -66,40 +66,35 @@ public class SecurityConfig {
}
else
{
cfg
.
setServiceProviderMetadataPath
(
"/tmp/sp_metadata.xml"
);
}
if
(
saml
.
getSp
().
getMaxAuthAge
()<=
0
)
{
cfg
.
setMaximumAuthenticationLifetime
(
Integer
.
MAX_VALUE
);
}
else
{
cfg
.
setMaximumAuthenticationLifetime
(
saml
.
getSp
().
getMaxAuthAge
());
cfg
.
setServiceProviderEntityId
(
saml
.
getSp
().
getEntityId
());
}
cfg
.
setSpLogoutRequestSigned
(
saml
.
getSp
().
isRequireLogoutRequestSigned
());
cfg
.
setSignatureAlgorithms
(
saml
.
getSp
().
getSigningMethods
());
cfg
.
setSignatureReferenceDigestMethods
(
saml
.
getSp
().
getDigestMethods
());
cfg
.
setServiceProviderEntityId
(
saml
.
getSp
().
getEntityId
());
cfg
.
setSpLogoutRequestSigned
(
saml
.
getSp
().
isLogoutRequestSigned
());
// TODO: What to do here?
//cfg.setAuthnRequestBindingType(SAMLConstants.SAML2_REDIRECT_BINDING_URI);
//cfg.setResponseBindingType(SAMLConstants.SAML2_POST_BINDING_URI);
cfg
.
setWantsAssertionsSigned
(
saml
.
getSp
().
isWantsAssertionsSigned
());
cfg
.
setWantsResponsesSigned
(
saml
.
getSp
().
isWantsResponsesSigned
());
//cfg.setNameIdPolicyFormat(nameIdPolicyFormat);
// TODO: Refactor old properties
cfg
.
setWantsAssertionsSigned
(
saml
.
getSp
().
isRequireArtifactResolveSigned
());
cfg
.
setWantsResponsesSigned
(
saml
.
getSp
().
isRequireLogoutResponseSigned
());
cfg
.
setAuthnRequestSigned
(
saml
.
getSp
().
isAuthnRequestSigned
());
// TODO: New properties
/*
cfg.setAuthnRequestSigned(true);
cfg.setSignatureAlgorithms(signatureAlgorithms);
cfg.setSignMetadata(true);
cfg
.
setSignMetadata
(
saml
.
getSp
().
isSignMetadata
());
SAML2HttpClientBuilder httpClient = new SAML2HttpClientBuilder();
httpClient.setConnectionTimeout(Duration.ofSeconds(2));
httpClient.setSocketTimeout(Duration.ofSeconds(2));
cfg.setHttpClient(httpClient.build());*/
// Static: Support only SAML2
List
<
String
>
supportedProtocols
=
new
ArrayList
<>();
supportedProtocols
.
add
(
SAMLConstants
.
SAML20_NS
);
cfg
.
setSupportedProtocols
(
supportedProtocols
);
cfg
.
setSupportedProtocols
(
saml
.
getSp
().
getSupportedProtocols
());
SAML2Client
samlClient
=
new
SAML2Client
(
cfg
);
...
...
dariahsp-sample/src/main/resources/application.yml
View file @
2066778e
...
...
@@ -32,10 +32,14 @@ auth:
maxAuthAge
:
-1
entityId
:
https://c105-229.cloud.gwdg.de/dme
signMetadata
:
true
signingAlgorithm
:
"
http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
requireArtifactResolveSigned
:
true
requireLogoutRequestSigned
:
true
requireLogoutResponseSigned
:
false
#signingMethods: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
#digestMethods: http://www.w3.org/2001/04/xmlenc#sha256, http://www.w3.org/2001/04/xmlenc#sha512
#supportedProtocols: urn:oasis:names:tc:SAML:2.0:assertion
authnRequestSigned
:
true
logoutRequestSigned
:
true
wantsAssertionsSigned
:
true
wantsResponsesSigned
:
false
httpClientTimoutMs
:
2000
requiredAttributes
:
-
stage
:
ATTRIBUTES
required
:
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment