Search code examples
spring-securityopenidgoogle-apps

Spring security and login using google


I implemented in my web application spring security login using google open id as it is described in the article

But is there a way to allow login for all members of some google apps domain, w/o listing explicitly all users?

Or, at least, keep users list, but make ids host-independent (now google generates different ids for each host of deployment)


Solution

  • We have done this by whitelisting the corresponding domains:

    • implement AuthenticationUserDetailsService<OpenIDAuthenticationToken>
    • override loadUserDetails() and check for the domain

    You can view the exact code on GitHub (Sample Code) or read about how we implemented Spring & OAuth here: https://techdev.io/en/developer-blog/using-spring-and-oauth-in-trackr