Skip to content
Snippets Groups Projects
Commit a9df5cd1 authored by Nicholas Blair's avatar Nicholas Blair
Browse files

fix: correct configuration to activate federation attributemapper

We can't just decorate with @Component, because the package edu.wisc.uwss.preauth isn't @ComponentScan'ned (edu.wisc.uwss.configuration.preauth is).

Corrected the logger for the Federated attributesmapper, it was incorrectly using the Default implementation (so you couldn't tell which class was lgogging).

Added a Maven profile to help test: combined-simulate-federation.
parent 7473eb54
No related branches found
No related tags found
1 merge request!15fix: correct configuration to activate federation attributemapper
......@@ -18,6 +18,7 @@ import org.springframework.security.core.userdetails.AuthenticationUserDetailsSe
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
import edu.wisc.uwss.preauth.FederatedPreauthenticatedUserDetailsAttributeMapper;
import edu.wisc.uwss.preauth.UWUserDetailsAuthenticationUserDetailsService;
/**
......@@ -67,6 +68,17 @@ public class PreAuthenticationSecurityConfiguration extends GlobalMethodSecurity
public AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> preAuthenticationUserDetailsService() {
return new UWUserDetailsAuthenticationUserDetailsService();
}
/**
* If the Spring {@link Profile} "edu.wisc.uwss.preauth.federation" is active, register
* an instance of {@link FederatedPreauthenticatedUserDetailsAttributeMapper}.
*
* @return an instance of {@link FederatedPreauthenticatedUserDetailsAttributeMapper}
*/
@Bean @Profile("edu.wisc.uwss.preauth.federation")
public FederatedPreauthenticatedUserDetailsAttributeMapper federationAttributeMapper() {
return new FederatedPreauthenticatedUserDetailsAttributeMapper();
}
/**
* {@inheritDoc}
*
......@@ -76,4 +88,5 @@ public class PreAuthenticationSecurityConfiguration extends GlobalMethodSecurity
protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}
}
# developer properties for simulating preauthentication (shib) environment
preauth.remoteUser=admin
preauth.headerNames=uid;wiscedupvi;cn;wisceduudds;mail;Shib-Identity-Provider
preauth.headerValues=admin;UW000A000;Amy Administrator;A535000;amy.administrator@demo.wisc.edu;https://logintest.wisc.edu/idp/shibboleth
preauth.headerNames=uid;eppn;wiscedupvi;cn;wisceduudds;mail;Shib-Identity-Provider
preauth.headerValues=admin;admin@wisc.edu;UW000A000;Amy Administrator;A535000;amy.administrator@demo.wisc.edu;https://logintest.wisc.edu/idp/shibboleth
# other preauth properties, default values shown
#preauth.pviHeader=wiscedupvi
#preauth.usernameHeader=uid
......
......@@ -24,8 +24,6 @@ import java.util.Enumeration;
*
* @author Benjamin Sousa
*/
@Component
@Profile("edu.wisc.uwss.preauth.federation")
public class FederatedPreauthenticatedUserDetailsAttributeMapper implements PreauthenticatedUserDetailsAttributeMapper {
private String eppnHeader = "eppn";
......@@ -40,7 +38,7 @@ public class FederatedPreauthenticatedUserDetailsAttributeMapper implements Prea
private String customLogoutPrefix = "/Shibboleth.sso/Logout?return=";
private String customLogoutSuffix = "/logout/";
private static final Logger logger = LoggerFactory.getLogger(Default.class);
private static final Logger logger = LoggerFactory.getLogger(FederatedPreauthenticatedUserDetailsAttributeMapper.class);
/**
* {@inheritDoc}
*
......
......@@ -112,7 +112,13 @@
<profile>
<id>combined-simulate-netid</id>
<properties>
<activeProfiles>local-users,preauth,preauth-simulate-netid,edu.wisc.uwss.simulated-shibboleth</activeProfiles>
<activeProfiles>local-users,preauth,preauth-simulate-netid</activeProfiles>
</properties>
</profile>
<profile>
<id>combined-simulate-federation</id>
<properties>
<activeProfiles>local-users,preauth,preauth-simulate-netid,edu.wisc.uwss.preauth.federation</activeProfiles>
</properties>
</profile>
</profiles>
......
......@@ -47,8 +47,16 @@
<p>Start VM with 'mvn clean install jetty:run -P combined-simulate-netid', visit http://localhost:8080/.</p>
<ol>
<li>Click 'Lazy with "ignorepreauth"', expect "anonymousUser".</li>
<li>Visit http://localhost:8080/index.html. Click 'Lazy authentication', expect JSON object representing UWUserDetails for 'Amy Administrator'.</li>
<li>Visit http://localhost:8080/index.html. Click 'Required authentication', expect JSON object representing UWUserDetails for 'Amy Administrator'.</li>
<li>Visit http://localhost:8080/index.html. Click 'Lazy authentication', expect JSON object representing UWUserDetails for 'Amy Administrator'. Confirm 'source' attribute is 'preauth'.</li>
<li>Visit http://localhost:8080/index.html. Click 'Required authentication', expect JSON object representing UWUserDetails for 'Amy Administrator'. Confirm 'source' attribute is 'preauth'.</li>
</ol>
<h3>combined-simulate-federation</h3>
<p>Start VM with 'mvn clean install jetty:run -P combined-simulate-netid', visit http://localhost:8080/.</p>
<ol>
<li>Click 'Lazy with "ignorepreauth"', expect "anonymousUser".</li>
<li>Visit http://localhost:8080/index.html. Click 'Lazy authentication', expect JSON object representing UWUserDetails for 'Amy Administrator'. Confirm 'source' attribute is 'edu.wisc.uwss.preauth.federation'.</li>
<li>Visit http://localhost:8080/index.html. Click 'Required authentication', expect JSON object representing UWUserDetails for 'Amy Administrator'. Confirm 'source' attribute is 'edu.wisc.uwss.preauth.federation'.</li>
</ol>
</body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment