Skip to content

Commit

Permalink
Merge pull request #11 from incuna/auth-header-prefix
Browse files Browse the repository at this point in the history
Add auth-header-prefix option
  • Loading branch information
perry committed May 23, 2014
2 parents 80ab6cc + f406519 commit f0e59b7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

# 3.0.3

* Add option for authorisation header prefix to allow oAuth 2.0 bearer authorisation

# 3.0.2

* Only broadcast tokenAuth events after cookie manipulation.
Expand Down
9 changes: 6 additions & 3 deletions angular_token_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
ENDPOINT: '/auth/',
LOGIN: '/login/',
LOGOUT: '/logout/',
LOGIN_REDIRECT_URL: '/'
LOGIN_REDIRECT_URL: '/',
AUTH_HEADER_PREFIX: 'Token'
});

auth.config(['$routeProvider', 'TOKEN_AUTH', 'PROJECT_SETTINGS', function ($routeProvider, TOKEN_AUTH, PROJECT_SETTINGS) {
Expand All @@ -25,13 +26,15 @@
});
}]);

auth.factory('authInterceptor', ['$rootScope', '$q', 'tokenFactory', function ($rootScope, $q, tokenFactory) {
auth.factory('authInterceptor', ['$rootScope', '$q', 'tokenFactory', 'TOKEN_AUTH', 'PROJECT_SETTINGS', function ($rootScope, $q, tokenFactory, TOKEN_AUTH, PROJECT_SETTINGS) {
var MODULE_SETTINGS = angular.extend({}, TOKEN_AUTH, PROJECT_SETTINGS.TOKEN_AUTH);

return {
request: function (config) {
config.headers = config.headers || {};
var token = tokenFactory.getToken();
if (token) {
config.headers.Authorization = 'Token ' + token;
config.headers.Authorization = MODULE_SETTINGS.AUTH_HEADER_PREFIX + ' ' + token;
}
return config;
},
Expand Down
5 changes: 3 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-token-auth",
"version": "3.0.2",
"version": "3.0.3",
"main": "./angular_token_auth.js",
"dependencies": {
"angular": "~1.2",
Expand All @@ -9,7 +9,8 @@
"homepage": "https://github.com/incuna/angular-token-auth",
"authors": [
"Perry Roper <[email protected]>",
"Anna Powell-Smith <[email protected]>"
"Anna Powell-Smith <[email protected]>",
"Graham Gilchrist <[email protected]>"
],
"license": "MIT",
"ignore": [
Expand Down

0 comments on commit f0e59b7

Please sign in to comment.