Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
47b581d3
Unverified
Commit
47b581d3
authored
3 years ago
by
Martin Weise
Browse files
Options
Downloads
Patches
Plain Diff
Revert some over-configuration, keeps redirecting
parent
147030fb
No related branches found
No related tags found
4 merge requests
!81
New stable release
,
!43
Merge dev to master
,
!33
Draft: merge dev to master
,
!30
Resolve "Refactor: fix all TODOs and FIXMEs in the backend"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
fda-authentication-service/rest-service/src/main/java/at/tuwien/config/SamlConfig.java
+12
-53
12 additions, 53 deletions
...st-service/src/main/java/at/tuwien/config/SamlConfig.java
with
12 additions
and
53 deletions
fda-authentication-service/rest-service/src/main/java/at/tuwien/config/SamlConfig.java
+
12
−
53
View file @
47b581d3
package
at.tuwien.config
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
;
import
org.apache.velocity.app.VelocityEngine
;
...
...
@@ -36,17 +35,12 @@ import org.springframework.security.saml.util.VelocityFactory;
import
org.springframework.security.saml.websso.*
;
import
org.springframework.security.web.*
;
import
org.springframework.security.web.access.channel.ChannelProcessingFilter
;
import
org.springframework.security.web.authentication.logout.LogoutHandler
;
import
org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler
;
import
org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler
;
import
org.springframework.security.web.authentication.www.BasicAuthenticationFilter
;
import
org.springframework.security.web.csrf.CsrfFilter
;
import
org.springframework.security.web.util.matcher.AntPathRequestMatcher
;
import
java.io.IOException
;
import
java.util.*
;
@Log4j2
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity
(
securedEnabled
=
true
)
...
...
@@ -161,7 +155,7 @@ public class SamlConfig extends WebSecurityConfigurerAdapter {
extendedMetadata
.
setIdpDiscoveryEnabled
(
true
);
extendedMetadata
.
setSignMetadata
(
true
);
extendedMetadata
.
setSigningKey
(
samlSignKey
);
extendedMetadata
.
setEncryptionKey
(
samlSignKey
);
//
extendedMetadata.setEncryptionKey(samlSignKey);
return
extendedMetadata
;
}
...
...
@@ -183,9 +177,7 @@ public class SamlConfig extends WebSecurityConfigurerAdapter {
public
CachingMetadataManager
metadata
(
ExtendedMetadataDelegate
extendedMetadataDelegate
)
throws
MetadataProviderException
{
final
List
<
MetadataProvider
>
providers
=
new
ArrayList
<>();
providers
.
add
(
extendedMetadataDelegate
);
CachingMetadataManager
metadataManager
=
new
CachingMetadataManager
(
providers
);
metadataManager
.
setDefaultIDP
(
idpProviderMetadata
);
return
metadataManager
;
return
new
CachingMetadataManager
(
providers
);
}
@Bean
...
...
@@ -235,39 +227,17 @@ public class SamlConfig extends WebSecurityConfigurerAdapter {
return
new
SAMLProcessorImpl
(
bindings
);
}
@Bean
public
SecurityContextLogoutHandler
logoutHandler
()
{
SecurityContextLogoutHandler
logoutHandler
=
new
SecurityContextLogoutHandler
();
logoutHandler
.
setInvalidateHttpSession
(
true
);
logoutHandler
.
setClearAuthentication
(
true
);
return
logoutHandler
;
}
@Bean
public
SAMLLogoutFilter
samlLogoutFilter
()
{
return
new
SAMLLogoutFilter
(
successLogoutHandler
(),
new
LogoutHandler
[]{
logoutHandler
()},
new
LogoutHandler
[]{
logoutHandler
()});
}
@Bean
public
SAMLLogoutProcessingFilter
samlLogoutProcessingFilter
()
{
return
new
SAMLLogoutProcessingFilter
(
successLogoutHandler
(),
logoutHandler
());
}
@Bean
public
FilterChainProxy
samlFilter
()
throws
Exception
{
List
<
SecurityFilterChain
>
chains
=
new
ArrayList
<>();
final
List
<
SecurityFilterChain
>
chains
=
new
ArrayList
<>();
chains
.
add
(
new
DefaultSecurityFilterChain
(
new
AntPathRequestMatcher
(
"/saml/login/**"
),
samlEntryPoint
()));
chains
.
add
(
new
DefaultSecurityFilterChain
(
new
AntPathRequestMatcher
(
"/saml/metadata/**"
),
metadataDisplayFilter
()));
chains
.
add
(
new
DefaultSecurityFilterChain
(
new
AntPathRequestMatcher
(
"/saml/SSO/**"
),
samlWebSSOProcessingFilter
()));
chains
.
add
(
new
DefaultSecurityFilterChain
(
new
AntPathRequestMatcher
(
"/saml/discovery/**"
),
samlIDPDiscovery
()));
chains
.
add
(
new
DefaultSecurityFilterChain
(
new
AntPathRequestMatcher
(
"/saml/login/**"
),
samlEntryPoint
()));
chains
.
add
(
new
DefaultSecurityFilterChain
(
new
AntPathRequestMatcher
(
"/saml/logout/**"
),
samlLogoutFilter
()));
chains
.
add
(
new
DefaultSecurityFilterChain
(
new
AntPathRequestMatcher
(
"/saml/SingleLogout/**"
),
samlLogoutProcessingFilter
()));
return
new
FilterChainProxy
(
chains
);
}
...
...
@@ -286,23 +256,12 @@ public class SamlConfig extends WebSecurityConfigurerAdapter {
http
.
csrf
()
.
disable
();
http
.
addFilterBefore
(
metadataGeneratorFilter
(),
ChannelProcessingFilter
.
class
)
.
addFilterAfter
(
samlFilter
(),
BasicAuthenticationFilter
.
class
)
.
addFilterBefore
(
samlFilter
(),
CsrfFilter
.
class
);
.
addFilterAfter
(
samlFilter
(),
BasicAuthenticationFilter
.
class
);
http
.
authorizeRequests
()
.
antMatchers
(
"/"
).
permitAll
()
// .antMatchers("/saml/**").permitAll()
// .antMatchers("/health").permitAll()
// .antMatchers("/error").permitAll()
.
anyRequest
()
.
authenticated
();
http
.
logout
()
.
addLogoutHandler
((
request
,
response
,
authentication
)
->
{
try
{
response
.
sendRedirect
(
"/saml/logout"
);
}
catch
(
IOException
e
)
{
log
.
error
(
"Failed to logout: {}"
,
e
.
getMessage
());
}
});
.
antMatchers
(
"/saml/**"
).
permitAll
()
.
antMatchers
(
"/health"
).
permitAll
()
.
antMatchers
(
"/error"
).
permitAll
()
.
anyRequest
().
authenticated
();
}
@Bean
...
...
This diff is collapsed.
Click to expand it.
Martin Weise
@mweise
mentioned in commit
483f2c85
·
3 years ago
mentioned in commit
483f2c85
mentioned in commit 483f2c85bb35cca4a4193167d75eea5e0c88fcd8
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment