Quantcast
Viewing all articles
Browse latest Browse all 4826

Ember doesn't include authorizer in request.Authorization fails

@Harun_Tuncay wrote:

Hi, i have an ember/express app and i am currently working on authenticaiton.I have implemented a 'jwt' based authentication.I thought it was working since 'session.isAuthenticated' returned true and i was able to visit 'secret' route.

When i check to see request headers to read user info, i saw there was no 'authorizer' header.I have tried to send back user info when making a get request to secret route, and it gave out errors.

app.get('/api/secret', passport.authenticate('jwt', { session: false }), function(req, res) {
  res.send({message: 'It worked! User id is: ' + req.user._id + '.'});
});

It returns 'Unauhtorized'.You can see i declared an authorizer in config/environment file.

  ENV['ember-simple-auth'] = {
    authorizer: 'authorizer:token'
  };
  ENV['ember-simple-auth-token'] = {
  identificationField: 'email',
  serverTokenEndpoint: 'http://localhost:3000/api/login',
  refreshAccessTokens: true,
  refreshLeeway: 300 // Refresh the token 5 minutes (300s) before it expires.
};

Here is the adapter & serializer.It might help

import DS from 'ember-data';

export default DS.RESTAdapter.extend({
  namespace: 'api',
  host: 'http://localhost:3000',
});

import DS from 'ember-data';

export default DS.RESTSerializer.extend({
    primaryKey: '_id',
  serializeId: function(id) {
      return id.toString();
  }
});

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles