Class SecurityConfiguration

  • All Implemented Interfaces:
    org.springframework.security.config.annotation.SecurityConfigurer<javax.servlet.Filter,​org.springframework.security.config.annotation.web.builders.WebSecurity>, org.springframework.security.config.annotation.web.WebSecurityConfigurer<org.springframework.security.config.annotation.web.builders.WebSecurity>

    @Configuration
    @EnableWebSecurity
    public class SecurityConfiguration
    extends org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
    This class contains our configuration for the web security on the server-side through google Oauth 2.0
    • Constructor Summary

      Constructors 
      Constructor Description
      SecurityConfiguration​(UserService userService)
      Constructor of our securityConfiguration, utilizing the userService.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void configure​(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
      This method configures the http security protocol with the jwt and the converter in user Service.
      org.springframework.security.oauth2.jwt.JwtDecoder jwtDecoder()
      a decoder method that takes the Oauth2.0 validation token and decodes it from the issuerUri, in our case google.
      • Methods inherited from class org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter

        authenticationManager, authenticationManagerBean, configure, configure, getApplicationContext, getHttp, init, setApplicationContext, setAuthenticationConfiguration, setContentNegotationStrategy, setObjectPostProcessor, setTrustResolver, userDetailsService, userDetailsServiceBean
    • Constructor Detail

      • SecurityConfiguration

        @Autowired
        public SecurityConfiguration​(UserService userService)
        Constructor of our securityConfiguration, utilizing the userService.
        Parameters:
        userService - UserService which holds the logic for authentication from Jwt.
    • Method Detail

      • configure

        protected void configure​(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
                          throws Exception
        This method configures the http security protocol with the jwt and the converter in user Service.
        Overrides:
        configure in class org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
        Parameters:
        http - an HttpSecurity object
        Throws:
        Exception - that is thrown when the user is not authenticated.
      • jwtDecoder

        @Bean
        public org.springframework.security.oauth2.jwt.JwtDecoder jwtDecoder()
        a decoder method that takes the Oauth2.0 validation token and decodes it from the issuerUri, in our case google. Then it checks the validation token against those in Google's record on the google cloud console. If the clientId and the Google cloud console issuerUri match up then it returns a validated decoder.
        Returns:
        a JwtDecoder object.