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

Support resolving issuer from current request #479

Closed
jacko9et opened this issue Nov 4, 2021 · 11 comments
Closed

Support resolving issuer from current request #479

jacko9et opened this issue Nov 4, 2021 · 11 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@jacko9et
Copy link

jacko9et commented Nov 4, 2021

The current issuer needs to be set in the configuration, can it be changed to dynamic? Or change ProviderSettings to be extensible.
Refer:ControllerLinkBuilder

@jacko9et jacko9et added the type: enhancement A general enhancement label Nov 4, 2021
@jgrandja
Copy link
Collaborator

jgrandja commented Nov 4, 2021

@lu-cheng Can you provide more detail on why the issuer needs to be resolved at runtime? Typically, the issuer is a host/domain name and is known at configuration/deployment time. Are you resolving using IP address? Is this for non-production environment?

@jgrandja jgrandja self-assigned this Nov 4, 2021
@jgrandja jgrandja added the status: waiting-for-feedback We need additional information before we can continue label Nov 4, 2021
@jacko9et
Copy link
Author

jacko9et commented Nov 4, 2021

@jgrandja Yes, part of the reason is due to environmental issues. If the IP address is fixed, it can be solved by passing parameters at runtime, but when the IP changes frequently and there is no fixed domain name, it is difficult to deal with. The other case is multi-tenancy (saas product), each tenant uses a different subdomain, and the auth-server uses the same set of service instances. At this time, a dynamic issuer is needed.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 4, 2021
@jgrandja
Copy link
Collaborator

jgrandja commented Nov 4, 2021

Thanks for the details @lu-cheng.
Let me think about this and I'll get back to you shortly.

@jgrandja jgrandja removed the status: feedback-provided Feedback has been provided label Nov 4, 2021
@jvalkeal
Copy link
Contributor

jvalkeal commented Nov 5, 2021

It would be nice if uri could be resolved from request as my attempt to run server on k8s and them attempted to point my boot app(running locally) to it. I did modify my /etc/hosts to point issue to localhost so that I can access minikube nodeport but boot app blows up with:

Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]:
  Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalStateException:
  The Issuer "http://sso.sso" provided in the configuration metadata did not match the requested issuer "http://sso.sso:32530"

When I had setting:

SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_SSO_ISSUER_URI=http://sso.sso:32530

i.e. keycloak changes things in .well-known/openid-configuration based on request which makes it relatively easy to setup with different networks.

@jgrandja
Copy link
Collaborator

jgrandja commented Nov 5, 2021

Thanks for the additional details @jvalkeal. I'll resolve this soon.

@markhobson
Copy link

Another use case, related to #258, is being able to set the issuer to local.server.port when running integration tests against the authorization server. The ProviderSettings must be configured on application startup, but the random port isn't known until after startup.

@jgrandja jgrandja changed the title Set issuer dynamically Support resolving issuer from current request Nov 15, 2021
@jgrandja
Copy link
Collaborator

@lu-cheng @jvalkeal @markhobson This is now resolved via 666d569.

Can you please confirm the enhancement resolves your specific issue? Thanks!

@jgrandja jgrandja added this to the 0.2.1 milestone Nov 15, 2021
@markhobson
Copy link

Hi @jgrandja, thanks for the change! I've tried my authorization server integration tests against 0.2.1-SNAPSHOT and they work fine when omitting the explicit issuer configuration and infer the random port.

A couple of 0.2.1 related issues I encountered on upgrading, in case it helps others here:

  1. Deprecate PasswordEncoder in JdbcRegisteredClientRepository #496 requires client secrets to be encoded externally
  2. Deny consent flow breaks when additional request parameters are present

@jgrandja
Copy link
Collaborator

@lu-cheng @jvalkeal @markhobson I've been mulling over the solution provided via 666d569 as I'm not quite happy with it. So I decided to revert the change before the release this week.

Unfortunately, it won't make it into 0.2.1 but I do plan on merging the improvements next week.

@jgrandja jgrandja reopened this Nov 29, 2021
@jgrandja jgrandja modified the milestones: 0.2.1, 0.2.2 Nov 29, 2021
@jgrandja
Copy link
Collaborator

@lu-cheng @jvalkeal @markhobson This is now resolved via d302444

@markhobson
Copy link

Works for me, thanks @jgrandja!

doba16 pushed a commit to doba16/spring-authorization-server that referenced this issue Apr 21, 2023
doba16 pushed a commit to doba16/spring-authorization-server that referenced this issue Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants