2015-02-05 2 views
1

Ember CLI 0.1.12에서 간단하고 작동하는 응용 프로그램을 사용했습니다. Ember Simple Auth addon을 Token 인증 자 및 권한 부여자를 사용합니다. https://github.com/jpadilla/ember-cli-simple-auth-tokenEmber Simple Auth (토큰 플러그인 포함)는 토큰과 함께 Authorization 헤더를 추가하지 않습니다.

먼저 서버가 무엇을 반환해야하는지 알지 못해서 인증 할 수 없었습니다. 인터넷 검색을 많이 후, 서버가 이런 식으로 뭔가를 반환해야 함을 알아낼 수 있었다 :

{ "access_token이": "ToKeN123hEre"}

가 지금은 인증과 세션이 작동 할 수 있었다. 그러나 다른 호출을하면 Authorization 헤더가 요청 헤더에 나타나지 않으므로 서버가 토큰을 알 수 없습니다.

이것은 내가 지금까지 시도한 것입니다 :

을 내 environment.js 파일을 설정 :

ENV['simple-auth'] = { 
    crossOriginWhitelist: ['*'], 
    authorizer: 'simple-auth-authorizer:token', 
    routeAfterAuthentication: '/profile' 
}; 

ENV['simple-auth-token'] = { 
    serverTokenEndpoint: '/api0/auth', 
    identificationField: 'username', 
    passwordField: 'password', 
    tokenPropertyName: 'token', 
    authorizationPrefix: 'Bearer ', 
    authorizationHeaderName: 'Authorization', 
    headers: {} 
}; 

내 서버를 사용 CORS를 확인하고 원점에서 인증 헤더와 요청을 할 수 있습니다.

답변

1

간단히 "토큰"으로 "access_token"을 변경하고 이제는 작동합니다.

+1

이것은 Rails가 authenticate_with_http_token 메소드를 사용하는 방법 때문에 ember-simple-auth에 막 생긴 새로운 변화입니다. 여기에서 문제보기 : https://github.com/simplabs/ember-simple-auth/issues/387 – bravely