You can totally use the SignIn Widget. I have not messed with EmberJS and our API, but you should be able to use the widget for sign in and using the API to do more complicated stuff (Creating users, etc).
Yeah it was a lot easier than I expected to hook in the sign in widget
One question I have is how should I handle authentication with my backend server if I use with sign in widget? Would I just send the token to the backend that is received back from the widget and then validate it?
I’m almost there, just still slightly confused on the flow/concepts a tad…
I have the sign in widget hooked into Ember, and I’m taking the access_token returned from Okta and sending that to my backend server.
Do I now using the Okta Java library validate the access token and return an id_token to the frontend? If that’s the case do I just throw away the id_token sent to me from the sign in widget? That seems a bit of a pointless exercise?
Or is the idea that I can send the access token to my backend server, confirm it is correct via the Java SDK, and then return a Principal user to the frontend client?
Sorry if these seem like silly questions, first time trying to really setup anything other than simple social logins.
On your backend, you can use our Spring Boot starter to protect your API and validate tokens. As far as returning a Principal to the front end, that’s an option. But you can also use the id_token since that has a lot of the user’s information in it.
But I’m still getting unauthenticated when trying to request my API, I assume the ResourceSecurityConfigurer class is handling dealing with the incoming token?
There is a lot of different blogs/tutorials for Okta with Spring but it’s hard to understand which one I should be following.
You should send just the access token to your API. It should be in a header named “Authentication” and be prefixed with "Bearer ". Here’s an TypeScript example from one of the Angular tutorials I wrote.
I’ve got that part covered, but that’s ahead of where I am at the moment.
I’ve just gotten the response from the Widget, I need to send that as a REST request to my backend to return a JWT or something (I’m not sure yet) to the client to complete the authentication process for Ember (using ember-simple-auth).
@PostMapping("/auth/login")
public Response authResponse(@RequestBody String oktaResponse) {
// Do something with data from sign in widget
return Response.status(Response.Status.OK).entity("Something Here").build();
}
Then all following calls will be handled with Authorization Bearer headers;
I guess it’s just the actual login with the backend service is where I’m stuck.
If you’re using the Okta Spring Boot Starter, you don’t need to post anything to your backend to authenticate. Sending the Bearer token is all you’ll need to access your endpoints.
I haven’t used ember-simple-auth, but I noticed it does have OAuth 2.0 support, so you might be able to use that (with Okta) instead of our SDKs.
Sweet! Glad you got it working. If you happen to write a blog post about integrating Ember with Okta, please let me know. We’d love to send you some traffic.
My last little hurdle to success… When copying the access token returned from the Okta Widget and using Postman to send a request, I’m getting invalid_token back from my backend.
I am however now receiving Access is denied (user is anonymous); redirecting to authentication entry point rather than invalid token, so progress I suppose.
Sorry for all the spam… Looks like my issue is to do with the fact I was trying to authenticate endpoints on a Zuul Proxy enabled host. When I move all the authentication to the actual services things work as expected (well, for the moment when skipping the proxy).
I guess Zuul handles incoming requests a little different and is something I’ll need to investigate further. mraible I have seen your post from August around this, any chance of an updated version?