Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set custom userInfoEndpoint user/oidc user service #136

Closed
bdemers opened this issue Jul 23, 2019 · 11 comments · Fixed by #146 or #154
Closed

Cannot set custom userInfoEndpoint user/oidc user service #136

bdemers opened this issue Jul 23, 2019 · 11 comments · Fixed by #146 or #154

Comments

@bdemers
Copy link
Contributor

bdemers commented Jul 23, 2019

This is caused by the use of a factory configured in META-INF/spring.factories

org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer = \
  com.okta.spring.boot.oauth.OktaOAuth2Configurer

Maybe we can change this logic to lookup a bean from the context instead. Otherwise, we might need to provide some other way to allow custom Authorities to be added to the current user.

@bdemers
Copy link
Contributor Author

bdemers commented Jul 23, 2019

@jkennedy4
Copy link

My use case for injecting my own code in the spring boot + oauth + okta flow is as follows. We will be supporting 3 different types of applications on our side: a legacy (JBOSS) app with spring xml-config and custom "homegrown" security, a JBOSS app with spring security and a spring boot app. We would like to add information to the OAuth2AuthenticationToken which is the object ultimately returned by Spring. We would like to add our own authorities to the existing ones added by oauth/okta. Also, we need to add a custom security user object to the http session which is used by the legacy app. This information comes from our Oracle database, and we will use the loginId (from Okta) as a key to lookup the Oracle data. That means our code HAS to follow the back-channel calls that are initiated from Spring's OidcAuthorizationCodeAuthenticationProvider.

@bdemers
Copy link
Contributor Author

bdemers commented Aug 28, 2019

@jkennedy4 Thanks that helps!

@msamm-r7
Copy link

msamm-r7 commented Nov 4, 2019

i have a very similar use case to @jkennedy4 , where i want to add to the authorities during auth.

@luupqvinh
Copy link

I have the same problem. I want to provide a custom oidc user service to add some custom authorities by querying a database.

bdemers added a commit that referenced this issue Nov 6, 2019
…ties

Converted existing code to use this new interface (scopes and groups)

Fixes: #136
@bdemers
Copy link
Contributor Author

bdemers commented Nov 6, 2019

Anyone watching this issue, I just created a PR with how I've been thinking about solving this. Feedback welcome!

TL;DR:

@Bean
AuthoritiesProvider myCustomAuthoritiesProvider() {
    return (user, userRequest) -> lookupExtraAuthoritesByName(user.getAttributes().get("email"));
}

(There is still a little bit of cleanup to do on this PR, but I think it should provide an easy way to add custom GrantedAuthorites)

@dcods22
Copy link

dcods22 commented Dec 10, 2019

Is there an update as to when this change would be in?

@bdemers
Copy link
Contributor Author

bdemers commented Dec 10, 2019

@dcods22 Can you take a look at #146 ? Would something like that work for you?

(I'm also trying to make sure you can set the UserServices as well)

@dcods22
Copy link

dcods22 commented Dec 11, 2019

@bdemers Yes that would work. Like you mentioned setting the user service would be super ideal too and would remove the need for this Authorities providers since you could then just override the user service that could extend off of yours and only override those methods. But this change would at least unblock us for now and let us leverage spring security properly which is ideal

bdemers added a commit that referenced this issue Jan 15, 2020
Previously we used an AbstractHttpConfigurer to set the Okta implementation of the OAuth2UserService (and oidc user service)
This made replacing Okta impl impossible to replace due to how/when those impls were configured.
Now they loaded automatically.

Fixes: #136
bdemers added a commit that referenced this issue Jan 22, 2020
Previously we used an AbstractHttpConfigurer to set the Okta implementation of the OAuth2UserService (and oidc user service)
This made replacing Okta impl impossible to replace due to how/when those impls were configured.
Now they loaded automatically.

Fixes: #136
bdemers added a commit that referenced this issue Jan 22, 2020
…ties

Converted existing code to use this new interface (scopes and groups)

Fixes: #136
bdemers added a commit that referenced this issue Jan 22, 2020
…ties

Converted existing code to use this new interface (scopes and groups)

Fixes: #136
bdemers added a commit that referenced this issue Jan 27, 2020
…ties

Converted existing code to use this new interface (scopes and groups)

Fixes: #136
@jevanlingen
Copy link

jevanlingen commented Jun 29, 2020

#146 added the authoritiesProviders to OktaOidcUserService and OktaOAuth2UserService classes. I am missing something, or should it also be added to the OktaJwtAuthenticationConverter class as well? I got a JWT token, but once it is validated it does not seem to cross named services, so I cannot set my own authorities for tokenized login users.

Edit: Did not check the other issues, but this comment clearly a duplicate with #160!

@bdemers
Copy link
Contributor Author

bdemers commented Jun 29, 2020

@jevanlingen +1
Let's move this conversation over to #160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants