Reputation: 401
Here's my workflow.
?token=
query parameter.What I'd like to do is work this in to a custom ember-simple-auth
authenticator
(and authorizer
?) in order to take advantage of the niceness of session and Authorization headers from there on.
Currently I've hacked an authenticator to do just the redirect to the identity provider. The rest of the API workflow is working. And I'm catching the token in a route on the way back and populating a User resource via a call to the database. But I feel that I'm heading down the wrong (and the long) path.
Any thoughts? Is this something that ember-simple-auth-token
is designed for?
Upvotes: 0
Views: 493
Reputation: 644
I solved this in last month. what i did was
here is the custom authenticator class
import Base from 'ember-simple-auth/authenticators/base';
import {isEmpty} from '@ember/utils';
export default Base.extend({
authenticate(data) {
return new Promise((resolve, reject) => {
if(data.access_token!=null){
resolve({
scope: data.scope,
access_token: data.access_token,
});
}else{
reject();
} })
},
restore(data) {
return new Promise((resolve, reject) => {
if (!isEmpty(data.access_token)) {
resolve(data);
} else {
reject();
}
});
},
});
i have created a route to handle in the frontend to get the token which is sent by backend. so the route takes sso token by a get param ( cause backend cannot do a post to emberapp) so when the route triggers i catch the param in route and do a post method again to validate the token.
we are using redis generated tokens. so since this question is asked about the emberjs i illustrated the answer to support you on frontend. i have illustrate the concept as well to show what you need to do. so its up to you to dig up and find more about it. like how to create temporary JWT token, how to validate it, how to redirect to you to your backend with claims from the adfs and etc. i think i provide answer to the initial question you asked which is "How to implement an Ember Simple Auth using an external redirect"
Upvotes: 0