Created
June 12, 2015 03:21
-
-
Save jhliberty/d8810b84dd91237db15b to your computer and use it in GitHub Desktop.
Basic JWT Auth for Seeds.js/Sane Stack (aka Ember on Sails)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ENV = { | |
modulePrefix: 'frontend', | |
environment: environment, | |
baseURL: '/', | |
locationType: 'auto', | |
EmberENV: { | |
FEATURES: { | |
// Here you can enable experimental features on an ember canary build | |
// e.g. 'with-controller': true | |
} | |
}, | |
'simple-auth': { | |
authorizer: 'simple-auth-authorizer:token', | |
serverTokenRevocationEndpoint: '/revoke', | |
crossOriginWhitelist: ['http://localhost:1776'], | |
routeAfterAuthentication: '/', | |
store: 'simple-auth-session-store:local-storage' | |
}, | |
'simple-auth-token': { | |
serverTokenEndpoint: 'http://localhost:1776/login', | |
identificationField: 'email' | |
}, | |
contentSecurityPolicy: { | |
'default-src': "'none'", | |
'script-src': "'self' 'unsafe-inline' 'unsafe-eval' http://cdnjs.cloudflare.com/", | |
'font-src': "'self' https://fonts.gstatic.com data:", | |
'connect-src': "'self' http://localhost:1776 http://localhost:3000", | |
'img-src': "'self' www.gravatar.com", | |
'report-uri':"'localhost'", | |
'style-src': "'self' 'unsafe-inline' https://fonts.googleapis.com http://cdnjs.cloudflare.com", | |
'frame-src': "'none'", | |
'media-src': "'self'" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/controllers/login.js | |
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
actions: { | |
authenticate: function() { | |
var credentials = this.getProperties('identification', 'password'), | |
authenticator = 'simple-auth-authenticator:token'; | |
this.get('session').authenticate(authenticator, credentials); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from "ember"; | |
Router.map(function() { | |
this.route('login'); | |
}); | |
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from "ember"; | |
import UnauthenticatedRouteMixin from 'simple-auth/mixins/unauthenticated-route-mixin'; | |
export default Ember.Route.extend(UnauthenticatedRouteMixin, { | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"devDependencies": { | |
"ember-cli-seeds-scaffold": "1.0.4", | |
"ember-cli-simple-auth": "0.8.0-beta.2", | |
"ember-cli-simple-auth-token": "0.7.2", | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.cors = { | |
allRoutes: true, | |
origin: 'http://localhost:4200', | |
headers: 'content-type, Authorization' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"sails-hook-jwt-auth": "^1.0.2" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment