Search code examples
ember.jsember-cliember-simple-auth

ember cli simple auth devise last version 0.8.0-beta.1


I am trying to set up ember cli simple auth devise in my app, actually I found many examples and similar issues but still not able to solve a problem that I am fighting many hours, it is the last version of the addon 0.8.0-beta.1, the authentication works perfect but when I try to visit a page under a token authorization, the token is not sending in the header: enter image description here

The thing I am thinking which causes this is the devise authorization in the config file, I have it the same described in the doc:

ENV['simple-auth'] = {
    authorizer: 'simple-auth-authorizer:devise'
}

I have the whole code in this repo, if you could give a feedback it will be really appreciated!!!

Updated 20/04/2015:

ENV['simple-auth'] = {
    authorizer: 'simple-auth-authorizer:devise',
    crossOriginWhitelist: ['*']
}

# config/application.rb 
# rack-cors configuration in the server side 
config.middleware.insert_before 0, "Rack::Cors" do
  allow do
    origins "*"
    resource "*",
      :headers => :any,
      :methods => [:get, :post, :delete, :put, :options, :head],
      :credentials => true
  end
end

result: enter image description here enter image description here


Solution

  • When your API is running on a different host/port you need to configure Ember Simple Auth's crossOriginWhitelist and list the API's origin there so Ember Simple Auth will inject the Authorization header. This is a security measure that makes sure that Auth tokens aren't sent with every request all over the Internet.