Class AadWebApplicationHttpSecurityConfigurer

java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<AadWebApplicationHttpSecurityConfigurer,org.springframework.security.config.annotation.web.builders.HttpSecurity>
com.azure.spring.cloud.autoconfigure.aad.AadWebApplicationHttpSecurityConfigurer
All Implemented Interfaces:
org.springframework.security.config.annotation.SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,org.springframework.security.config.annotation.web.builders.HttpSecurity>

public class AadWebApplicationHttpSecurityConfigurer extends org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<AadWebApplicationHttpSecurityConfigurer,org.springframework.security.config.annotation.web.builders.HttpSecurity>
HTTP security configurer class for Azure Active Directory Web application scenario, used to make Azure client registration repository and OAuth2 request entity converter take effect.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.springframework.beans.factory.ObjectProvider<com.azure.spring.cloud.autoconfigure.aad.implementation.oauth2.OAuth2ClientAuthenticationJwkResolver>
    JWK resolver implementation for client authentication.
    protected org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest,org.springframework.security.oauth2.core.oidc.user.OidcUser>
    OIDC user service.
    AAD authentication properties
    protected org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
    A repository for OAuth 2.0 / OpenID Connect 1.0 ClientRegistration(s).
    protected org.springframework.boot.web.client.RestTemplateBuilder
    restTemplateBuilder bean used to create RestTemplate for Azure AD related http request.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Default configuer for Web Application with Azure AD.
    protected org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient<org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest>
    Gets the access token response client.
    conditionalAccessFilter(jakarta.servlet.Filter conditionalAccessFilter)
    Return the filter to handle conditional access exception.
    void
    configure(org.springframework.security.config.annotation.web.builders.HttpSecurity builder)
     
    void
    init(org.springframework.security.config.annotation.web.builders.HttpSecurity builder)
     
    protected org.springframework.security.web.authentication.logout.LogoutSuccessHandler
    Gets the OIDC logout success handler.
    protected org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver
    Gets the request resolver.

    Methods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer

    disable, getSecurityContextHolderStrategy, withObjectPostProcessor

    Methods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter

    addObjectPostProcessor, and, getBuilder, postProcess, setBuilder

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • repo

      protected org.springframework.security.oauth2.client.registration.ClientRegistrationRepository repo
      A repository for OAuth 2.0 / OpenID Connect 1.0 ClientRegistration(s).
    • restTemplateBuilder

      protected org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder
      restTemplateBuilder bean used to create RestTemplate for Azure AD related http request.
    • oidcUserService

      protected org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest,org.springframework.security.oauth2.core.oidc.user.OidcUser> oidcUserService
      OIDC user service.
    • properties

      protected AadAuthenticationProperties properties
      AAD authentication properties
    • jwkResolvers

      protected org.springframework.beans.factory.ObjectProvider<com.azure.spring.cloud.autoconfigure.aad.implementation.oauth2.OAuth2ClientAuthenticationJwkResolver> jwkResolvers
      JWK resolver implementation for client authentication.
  • Constructor Details

    • AadWebApplicationHttpSecurityConfigurer

      public AadWebApplicationHttpSecurityConfigurer()
  • Method Details

    • init

      public void init(org.springframework.security.config.annotation.web.builders.HttpSecurity builder) throws Exception
      Specified by:
      init in interface org.springframework.security.config.annotation.SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,org.springframework.security.config.annotation.web.builders.HttpSecurity>
      Overrides:
      init in class org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,org.springframework.security.config.annotation.web.builders.HttpSecurity>
      Throws:
      Exception
    • configure

      public void configure(org.springframework.security.config.annotation.web.builders.HttpSecurity builder) throws Exception
      Specified by:
      configure in interface org.springframework.security.config.annotation.SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,org.springframework.security.config.annotation.web.builders.HttpSecurity>
      Overrides:
      configure in class org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,org.springframework.security.config.annotation.web.builders.HttpSecurity>
      Throws:
      Exception
    • aadWebApplication

      public static AadWebApplicationHttpSecurityConfigurer aadWebApplication()
      Default configuer for Web Application with Azure AD.
      Returns:
      the configuer instance to customize the SecurityConfigurer
    • conditionalAccessFilter

      public AadWebApplicationHttpSecurityConfigurer conditionalAccessFilter(jakarta.servlet.Filter conditionalAccessFilter)
      Return the filter to handle conditional access exception. No conditional access filter is provided by default.
      Parameters:
      conditionalAccessFilter - the conditional access filter
      Returns:
      a filter that handles conditional access exception.
      See Also:
    • oidcLogoutSuccessHandler

      protected org.springframework.security.web.authentication.logout.LogoutSuccessHandler oidcLogoutSuccessHandler()
      Gets the OIDC logout success handler.
      Returns:
      the OIDC logout success handler
    • accessTokenResponseClient

      protected org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient<org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest> accessTokenResponseClient()
      Gets the access token response client.
      Returns:
      the access token response client
    • requestResolver

      protected org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver requestResolver()
      Gets the request resolver.
      Returns:
      the request resolver