Skip to content
Snippets Groups Projects
  1. May 18, 2016
    • Nicholas Blair's avatar
      Merge branch 'userdetailsservice-callback' into 'master' · 54b95e3c
      Nicholas Blair authored
      feature: a callback interface allowing customization of UserDetailsService#loadUserByUsername
      
      This pull request adds a callback interface that allows downstream projects to participate in one of the core Spring Security components of the `local-users` profile: the UserDetailsService.
      
      During an authentication attempt, `UserDetailsService#loadUserByUsername` is used by Spring Security to first check if a User object exists for the username in the credentials. If no User object is found, no further credential check takes place; if a User object is found, other Spring Security components go about comparing the provided credentials in the authentication attempt to that object.
      
      We have a use case in DoIT Number that is driving the need for this. DoIT Number has a custom `UWUserDetails` class that has some additional fields stored behind a DAO. If we didn't have this customization, DoIT Number would need to sub-class `LocalUserDetailsManagerImpl`, then somehow exclude that bean from the UWSpringSecurityConfiguration - not trivially possible.
      
      The existing `LocalUserDetailsAttributesMapper` interface has a lifecycle that's not conducive to this type of request. Implementations of that interface are executed during application startup - and it is possible that the DAO may not be fully constructed at the time it's queried. We need a callback that fires at time of authentication attempt - not startup.
       
      With this pull request, DoIT Number will simply have to register a Spring Bean as follows to query that DAO and attach the necessary data to their custom `UWUserDetails` class as part of `UserDetailsService#loadUserByUsername`:
      
      ```
      @Component
      class DNumberLocalUWUserDetailsCallback implements LocalUWUserDetailsCallback<DNumberUserDetailsImpl> {
      
        @Autowired
        private ControlDao controlDao;
      
        public void success(DNumberUserDetailsImpl userDetails) {
          userDetails.setControls(controlDao.getControls(userDetails.getUsername()));
        }
      }
      ```
      
      This type of feature is only needed for `local-users` and not for `preauth`. The `PreauthenticatedUserDetailsAttributeMapper` interface has a lifecycle already similar to LocalUWUserDetailsCallback (firing on authentication attempt, not startup). 
      
      Notify @alundholm 
      
      See merge request !12
      54b95e3c
    • Nicholas Blair's avatar
      fix: remove test cruft · 1e9fbbdd
      Nicholas Blair authored
      1e9fbbdd
    • Nicholas Blair's avatar
  2. May 17, 2016
  3. May 16, 2016
  4. Mar 11, 2016
  5. Mar 09, 2016
    • Andy Summers's avatar
      Add PviAttributeBindingFilter · 98f7248f
      Andy Summers authored
      PviAttributeBindingFilter is a filter that binds the currently
      authenticated user's PVI to the request as an attribute with the key
      "wiscedupvi".
      
      Switch to Map<String, String> for attributes
      
      Using a Map allows for multiple attributes to be added to the request.
      
      Change to AttributeBindingFilter for user specific attributes
      
      Filter supports UWUserDetails style attributes (such as `wiscedupvi`) for
      adding attributes specific to an authenticated user to a request.
      
      Change to PviAttributeBindingFilter
      
      The filter only needs to add a user's PVI as an attribute.
      
      Add type check for principal
      
      Principal is not always guaranteed to be a UWUserDetails instance at the
      point it will hit this filter.
      98f7248f
  6. Mar 03, 2016
  7. Feb 29, 2016
  8. Feb 25, 2016
    • Nicholas Blair's avatar
      Merge branch 'flexible-identifiers' into 'master' · 8ff50507
      Nicholas Blair authored
      Add IdentifiersFactory for more configurable UDS UserDetailsService
      
      Defaults to same behavior (treat argument to loadUserByUsername as a NetID username), but allows for easy override with PVI and others.
      
      Use case: consider STAR. star-war supports impersonation via 'On-Behalf-Of' header. Inside the `SwitchUserOnHeaderFilter` is a reference to a `UserDetailsService`. The user attribute value of the 'On-Behalf-Of' header is passed into that `UserDetailsService#loadUserByUsername(String)` method.
      Prior to this contribution, `UdsPersonUserDetailsServiceImpl` could ONLY accept a NetID username. 
      
      This contribution defaults to that same behavior. However, if one wants to use a different user attribute, they would simply add a `@Bean` to their Spring ApplicationContext:
      
      ```java
      @Bean
      public IdentifiersFactory pviIdentifiersFactory() {
        return new IdentifiersFactory.PVI();
      }
      ```
      
      With the magic of `@Autowired(required=false)`, the default Netid configuration is replaced, and one can now pass PVIs into the `SwitchUserOnHeaderFilter`.
      
      A few other interested parties: @paul.erickson @ahoffmann @bjsousa 
      
      See merge request !6
      8ff50507
    • Nicholas Blair's avatar
      Add IdentifiersFactory for more configurable Uds UserDetailsService · 046ce483
      Nicholas Blair authored
      Defaults to same behavior (treat argument to loadUserByUsername as a NetID username), but allows for easy override with PVI and others.
      046ce483
  9. Feb 24, 2016
  10. Feb 23, 2016
  11. Feb 19, 2016
  12. Feb 02, 2016
    • Benjamin Sousa's avatar
    • Benjamin Sousa's avatar
    • Nicholas Blair's avatar
      Merge branch 'highlander' into 'master' · 6181dc20
      Nicholas Blair authored
      Correctly support fallback to local-users in the absence of SAML2 attributes when both local-users and preauth are active
      
      The theme for this pull request:
      
      ![highlander](/uploads/f5de15a7b74cf0ba100c8326410f2eb2/highlander.jpg)
      
      This refactor was needed as the prior code did not fully support the 'combined' approach with both local-users and preauth. In the previous iteration, 2 `WebSecurityConfigurerAdapters` and as a result, 2 `HttpSecurity` instances would have been registered, only one having any affect (typically the preauth, but not guarantees). Spring Security does not provide support for multiple `HttpSecurity` instances, there should be only one.
          
      With this pull request, there is now only one WebSecurityConfigurerAdapter, whose sole purpose is to collect all HttpSecurityAmenders and execute their callback at the right time.  Te existing WebSecurityConfiguration classes for both profiles have been retrofitted to produce HttpSecurityAmenders that perform the desired behavior. The test cases provided in the sample-war have been updated to provide 2 combined test paths:
          
      * 1 that has both profiles active, but demonstrates how fallback to HTTP Basic works, and
      * 1 that has both profiles active, and includes the simulation filter to produce a successful preauthentication.
      
      See merge request !3
      6181dc20
Loading