This repository has been archived by the owner on Feb 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Home
Tobe O edited this page Dec 13, 2016
·
6 revisions
angel_auth
is a port of Passport to the Angel Framework.
// Of course, create an instance.
var auth = new AngelAuth();
// The following two functions de/serialize a user from a JWT.
auth.serializer = (user) async => serializeUserToId();
auth.deserializer = (id) async => deserializeUserFromId();
// Strategies are used to implement authentication methods
auth.strategies.add(new LocalAuthStrategy((username, password) async {
return await findCorrespondingUser(username, password);
});
// Use `authenticate` to log users in
var app = new Angel()..post('/auth/local', auth.authenticate('local'));
// Finally, call our instance as a plugin.
//
// This will a global middleware to decode JWT's and deserialize them,
// and also creates a route to refresh JWT's.
await app.configure(auth);