Meta for Pub score
This commit is contained in:
parent
5a2312e4eb
commit
dc2832cff8
2 changed files with 39 additions and 2 deletions
37
example/example.dart
Normal file
37
example/example.dart
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'package:angel_auth/angel_auth.dart';
|
||||||
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
|
|
||||||
|
main() async {
|
||||||
|
var app = new Angel();
|
||||||
|
var auth = new AngelAuth<User>();
|
||||||
|
|
||||||
|
auth.serializer = (user) => user.id;
|
||||||
|
|
||||||
|
auth.deserializer = (id) => fetchAUserByIdSomehow(id);
|
||||||
|
|
||||||
|
// Middleware to decode JWT's and inject a user object...
|
||||||
|
app.fallback(auth.decodeJwt);
|
||||||
|
|
||||||
|
auth.strategies['local'] = new LocalAuthStrategy((username, password) {
|
||||||
|
// Retrieve a user somehow...
|
||||||
|
// If authentication succeeds, return a User object.
|
||||||
|
//
|
||||||
|
// Otherwise, return `null`.
|
||||||
|
});
|
||||||
|
|
||||||
|
app.post('/auth/local', auth.authenticate('local'));
|
||||||
|
|
||||||
|
var http = new AngelHttp(app);
|
||||||
|
await http.startServer('127.0.0.1', 3000);
|
||||||
|
|
||||||
|
print('Listening at http://127.0.0.1:3000');
|
||||||
|
}
|
||||||
|
|
||||||
|
class User {
|
||||||
|
String id, username, password;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<User> fetchAUserByIdSomehow(id) async {
|
||||||
|
// Fetch a user somehow...
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
name: angel_auth
|
name: angel_auth
|
||||||
description: A complete authentication plugin for Angel.
|
description: A complete authentication plugin for Angel. Includes support for stateless JWT tokens, Basic Auth, and more.
|
||||||
version: 2.0.0
|
version: 2.0.0+1
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel_auth
|
homepage: https://github.com/angel-dart/angel_auth
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue