Open MarcelTon opened 5 years ago
Hey @MarcelTon!
Okta has two different types of issuers one for the Okta Dashboard/Admin console this is typically formatted as https://company.okta.com
the other is for API Access Management (any of your applications) and is typically seen as: https://company.okta.com/oauth2/default
Our Spring integration performs local validation of the access token by default, and this can ONLY be done for the API Access Management issuer (so this is likely why one worked and the other didn't)
You can work around this by validating the access token remotely by setting the property okta.oauth2.localTokenValidation=true
(or equivalent yaml).
That said, Spring Security 5, does NOT yet support remote token validation. So this is a bit of a dead end for the short term (and because of this, this property will NOT work with our major next release)
The easiest path forward is to use the /oauth2/default
style issuer.
Which leads us to the 401
, I'm not following this part completely, you mentioned said it worked well, but in some cases you get a 401? Can you clarify this part?
Hi @bdemers , thank you for your quick response. I have removed the part of my colleague being able to run the server, miscommunication. He can get a flow working with just the client, but obviously doesn't get any cool car list!
My title was unclear, I will try to clarify on the 401 (1 and 2) and would like to ask a follow-up question regarding the API Access Management issuer (3).
issuer: https://company.okta.com
for the server I receive the InvocationTargetException with the "String index out of range".issuer: https://company.okta.com/oauth2/default
for the server I receive the IllegalStateException with the "JwkTokenStoreConfiguration: 401 Unauthorized". This is reproducible behaviour simply done by a fresh checkout (and verified by my colleagues so I was sure I wasn't losing it), changing the two config parameters and running ./mvnw spring-boot:run
from the server dir. The problem might very well lie with the 401, I just don't really know where to proceed in Okta to solve this access problem!
I will play around with the LocalTokenValidation
and see if it offers more insight, thank you again!
EDIT: I removed the "it works for my colleague"-stuff, we all can not run the server app and have the same errors for java8 and java11.
@MarcelTon
What comes back from a request to https://company.okta.com/oauth2/default/.well-known/openid-configuration
(from your browser)?
issuer: https://company.okta.com
for the server I receive the InvocationTargetException with the "String index out of range".I think that you should set the org-url: okta.client.org-url= https://company.okta.com
For a https://company.okta.com
server without Authorization server, you must validate the idToken, you need set security.oauth2.resource.jwk.key-set-uri=https://company.okta.com/oauth2/v1/keys security.oauth2.client.client-id={$client.id}
in your application.properties and remove the okta oauth2.
And you need add:
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
resources.resourceId("${aud}");
}
in the ResourceServerConfigurerAdapter
class.
I can not run the server with "our company" configuration and am unsure why. After creating an SPA Client in Okta with OpenID Connect I clone the project. I adjust the configuration as follows:
application.yml:
app.module.ts:
Java version:
Maven version:
JAVA_HOME:
If I then run
./mvnw spring-boot:run
from theserver
folder I get the following error:If I change my config to the below "default" from the clone my backend runs just fine.
application.yml:
Obviously I can't onboard users that way haha, but it runs. If I use https://company.okta.com/oauth2/default by the way (this isn't what is shown in the Issuer field in Okta, but just in case) I receive the following error:
Could you tell me what I can try/provide to get it running on my machine? I'm at my wits end. Using Java11 + the Issuer as shown in Okta gives the same error, albeit formatted a little differently: