Skip to content

Commit

Permalink
Added support for Basic Authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
hrcornejo committed Oct 2, 2023
1 parent 7e38ee8 commit aed31e9
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import com.atlassian.crowd.integration.http.util.CrowdHttpValidationFactorExtractor;
import com.atlassian.crowd.integration.http.util.CrowdHttpValidationFactorExtractorImpl;
import com.atlassian.crowd.integration.rest.service.factory.RestCrowdClientFactory;
import com.atlassian.crowd.integration.springsecurity.CrowdLogoutHandler;
import com.atlassian.crowd.integration.springsecurity.CrowdSSOTokenInvalidException;
import com.atlassian.crowd.integration.springsecurity.RemoteCrowdAuthenticationProvider;
import com.atlassian.crowd.integration.springsecurity.UsernameStoringAuthenticationFailureHandler;
import com.atlassian.crowd.integration.springsecurity.*;
import com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetails;
import com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetailsService;
import com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetailsServiceImpl;
Expand Down Expand Up @@ -55,6 +52,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.DataAccessException;
import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand Down Expand Up @@ -351,7 +349,21 @@ CrowdUserDetails updateCrowdUserDetails(CrowdUserDetails crowdUserDetails) {
@Bean
public RemoteCrowdAuthenticationProvider crowdAuthenticationProvider() throws IOException {
return new RemoteCrowdAuthenticationProvider(
crowdClient(), httpAuthenticator(), crowdUserDetailsService());
crowdClient(), httpAuthenticator(), crowdUserDetailsService()) {

/**
* Added support for Basic Authentication using WebAuthenticationDetails
*
* @param authenticationToken AbstractAuthenticationToken
* @return support status
*/
public boolean supports(AbstractAuthenticationToken authenticationToken) {
// support all non-SSO authentication requests (for compatibility)
return (authenticationToken.getDetails() == null
|| authenticationToken.getDetails() instanceof CrowdSSOAuthenticationDetails
|| authenticationToken.getDetails() instanceof WebAuthenticationDetails);
}
};
}

@Bean
Expand Down

0 comments on commit aed31e9

Please sign in to comment.