lundi 4 juillet 2016

make custom API call with authentication

I am trying to develop an application that should eventually replace an existing (non-Ember) one and provide additional functionality.

For a start, for anything not yet implemented in the new app, I want to redirect users to the existing one, using the latter's single-sign-on capability. The workflow I imagined is this:

  1. User logged in to new (Ember) app clicks link or button there
  2. New app makes an API call to an endpoint that returns an SSO token
  3. New app generated link including SSO token, opens it (in new or same window)

I use ember-simple-auth to authenticate the user for API calls that return user-specific information, using a JSON web token that contains the user id.

For step 2 above I would need to include that token in the API call, but I am at loss how, and even where to implement the call. Do I need an Ember.Route for this (where I could throw in the AuthenticatedRouteMixin)? I would not consider the SSO token to be part of my model, so that does not seem right. Can I get the session's token somehow and include it in a direct ajax call? Should I?




Aucun commentaire:

Enregistrer un commentaire