-
Notifications
You must be signed in to change notification settings - Fork 232
Okta-react support for Auth Flow with PKCE #348
Comments
This is currently a platform feature gap, as the OAuth 2.0 Our API teams are actively working on opening up this endpoint, however there is no ETA on when we can expect to see this feature gap addressed. |
Hi all, thank you! |
@reste85 It's the same issue. The |
Hello, Is the only way to forfeit Okta's JS/React SDK's and instead configure the app in Okta dashboard as a "Native app" along with manually hit the |
@quanda That's correct (for now). Here's what we plan to do:
This issue is the place to watch for updates. |
It seems that CORS/PKCE is now supported. Are there plans to start active work on this? https://developer.okta.com/blog/2019/05/01/is-the-oauth-implicit-flow-dead |
Active work is already underway. PKCE support has been added to AuthJS ( Updating the various Front-end frameworks will also follow Soon(:tm:) |
I see that there is active work for React, is there anything active going on for the angular client? |
@rcollette - Yes, the Angular SDK is slated to add PKCE options following the React SDK. |
Okta React SDK PKCE Support is released in v1.2.2 (credit to @aarongranick-okta who implemented it). The other SDKs and related samples are up next. |
All, we have a React.js based SPA and we want to do SSO using OKTA. This capability "Auth flow with PKCE" seem to be the best approach and advanced and appropriate than the implicit flow. However, I have a question on how to handle the resource server authentication of the resource along with the SPA. Any suggestions. My scenario is: |
Hello @kkmathigir. Yes, you can configure your Spring Boot app with Okta and have React send the access token. Our Spring Boot Starter makes that pretty easy to do. I've written a couple blog posts about it on https://developer.okta.com/blog. For example: |
Appreciate your response @mraible . We will try this out and get back. Let the React do the 2 legged auth with authorization flow and PKCE and get the JWT/access token. the same access token is expected to be passed on to spring boot app. the spring boot app need to be configured with okta security as well. Spring boot app will validate the JWT and allow resource access. - Please confirm if my understanding is correct. Thanks! |
Yes, your understanding is correct. The only thing more secure is to package your React app with your Spring Boot app and use auth code flow with Spring Boot. That's how we do it in JHipster (a React + Spring Boot application generator). The 2nd blog post I referenced shows how to do that, in the Configure Maven to Build and Package React with Spring Boot section. |
Thanks @mraible . Can you clarify more on what you mean by "more secure". What will we lack with following #348 approach of React with auth flow with pkce vs packaging react app with springboot app (api). As such, I thought auth flow with pkce in a static react app will be secure enough than the previous implicit flow and i no more have to bundle the react app with spring boot. As such, we are already bundling react app with spring boot app, but has overhead in terms of making releases for react and api and everytime both of these components gets deployed vs i want to have a separate release cycles for react changes and api/springboot changes. |
@rcollette et al - PKCE flow support has been added to the the various Okta JS front end SDKs (okta-angular 1.2.2, okta-react 1.2.3 , okta-vue 1.2.3) and their associated sample repos ( Credit and props to @aarongranick-okta ) I'm closing this ticket as the issue is resolved. |
@kkmathigir Packaging the apps in the same artifact is more secure because you can use Spring Security's OAuth support with a client secret and the communication to your authorization server happens on the back channel. This means the tokens never get passed over the front channel and the end user never sees the exchange happening. |
Thanks for your response @mraible . It makes sense. |
@mraible I'm reading all your posts, but none of them seem to answer the questions around using Okta with a pure Spring Boot resource server. it all basically boils down to a simple fact: I DO NOT HAVE A CLIENT SECRET I have a vanilla JS UI served from S3 that uses https://www.npmjs.com/package/@okta/okta-auth-js to make use of PKCE and auth my user at our corporate Okta instance. My UI works as expected and I'm getting both an ID and Access Token now, in my spring boot app that hosts REST API endpoints, I want to authenticate all requests have a Bearer token in the Authorization header. what Okta deps should I use? I've spent three days trying to make sense of these different Git repos:
I can't find a single example that doesn't expect a client secret at some point. is okta/okta-spring-boot#132 still an issue...cause it sure seems like it is? how about okta/okta-spring-boot#147 Please provide some sanity to this mess of code samples and out of date documentation. |
You don't need a client ID or secret with Spring Boot if you just want JWT validation. All you need is the Okta Spring Boot starter and an issuer defined. See an example in our Java REST API blog post. As far as PKCE support in our starter, that's an open issue. |
Does that mean I won't be able to actually do the authentication? Or does that mean if I'm serving my client from my server I wouldn't be able to use PKCE? |
There's two different concepts: authentication and authorization. Authentication means when you hit your secured endpoint, you're redirected to Okta to log in, then back to your endpoint. Authorization is simply validation of the bearer token to make sure it's valid. If you hit the endpoint with PKCE is all about authentication. If you're setting up a resource server, you only need authorization, not authentication. |
Yes, my JS client is what issues the redirect to okta, handles the return with the code and ultimately stores tokens in browser storage. My API simply needs to validate the token passed in is valid and was issued for the client that was used by the UI. I don't want tokens issued by okta for other applications to be allowed to access my applications resource server. I read on one of the numerous blog posts that by providing okta spring boot the client ID it would perform that check |
And just to be clear I don't want my resource server to ever redirect me to okta.... It should simply return the 401. |
Thanks @aarongranick-okta that looks helpful. Now I just need to figure out the correct version of your starter to use with my app as it appears there are compatibility issues at certain versions based on the open issues mentioned above |
What version of Spring Boot are you using?
… On May 21, 2020, at 18:00, Jason Berk ***@***.***> wrote:
Thanks @aarongranick-okta that looks helpful. Now I just need to figure out the correct version of your starter to use with my app as it appears there are compatibility issues at certain versions based on the open issues mentioned above
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@jasonrberk The access token is in a standard "JWT" format and it can be verified using any library which understands it. So you don't necessarily need to work with the springboot, although it probably offers some conveniences. I think (but am not 100% sure) that our SDK is using To verify the token you will need to cryptographically verify the signature. This is not the 'clientSecret' that is used by server-side OAuth applications (You are using PKCE in a SPA/client-side application, which is totally fine). The (RSA) key will come from a "well known" endpoint. For example: https://aarongranick.oktapreview.com/.well-known/openid-configuration gives the "jwks_url": These details are handled for you by the higher level SDK, but may be helpful to understand, especially if you decide to use a lower-level SDK |
org.springframework.boot I thought the whole idea was to add the okta SB starter??? What's the difference between the starter and the SDK and why would I choose to use one over the other. Surely the idea of protecting a resource server with an OAuth 2 token can't possibly be this nuanced or difficult. as I shared with Matt I've yet to see an example that assumes pure oauth2 oidc protected resource server. most of the tutorials I've seen thus far spent more time setting up react or graphQL or some other external framework or dependency and very little time actually showing you how to use the okta tooling. I'll be digging into this pretty much all day tommorow and I do greatly appreciate everyone's help |
I keep getting this error: 2020-05-22 10:57:50.252 user:[] DEBUG 36265 --- [nio-8080-exec-1] .o.s.r.w.BearerTokenAuthenticationFilter : Authentication request for failed: org.springframework.security.oauth2.core.OAuth2AuthenticationException: An error occurred while attempting to decode the Jwt: Couldn't retrieve remote JWK set: org.springframework.web.client.HttpClientErrorException$NotFound: 404 Not Found |
Sounds like the issuer url may not be set correctly. It should be the url for your authorization server (okta org)/oauth2/(auth server id) |
in bootstrap.yml:
here's my okta account: and here's the error I'm getting: Authentication request for failed: org.springframework.security.oauth2.core.OAuth2AuthenticationException: An error occurred while attempting to decode the Jwt: Signed JWT rejected: Another algorithm expected, or no matching key(s) found and here's my decoded token
|
I created a fresh spring boot project following this guide: https://developer.okta.com/docs/guides/protect-your-api/springboot/before-you-begin/ I turned up the spring security logs and see this:
|
@jasonrberk Thanks for posting the detailed information. Your access token shows the issuer that minted it:
I think this might be the problem. Looks like the frontend app is configured to use the okta org as the issuer, rather than the custom authorization server. The frontend SPA app should be configured with the same exact issuer as the backend springboot project. So the issuer should be set to |
ok, now how do I get the authenticated user information.... It appears to have auth'd me, but now I get this error.... seems the injected OidcUser is NULL????
my application.yml is
and my sample controller is
and my security config is
|
the discussion in okta/okta-spring-boot#132 leads me to think I need to setup users, groups, apps and Auth Servers in my okta instance to get what I want.... |
I'm submitting this issue for the package(s):
I'm submitting a:
Current behavior
The Okta-react library currently supports OAuth 2.0 Implicit Grant authorisation flow.
Expected behavior
The Okta-React library should support OAuth 2.0 Authorisation with PKCE as recommended here: https://tools.ietf.org/html/draft-ietf-oauth-security-topics-09#section-2.1.2
Extra information about the use case/user story you are trying to implement
Our organisation's security architects are mandating Auth Code with PKCE, due to the potential known attacks on implicit grant.
The text was updated successfully, but these errors were encountered: