Bump to 2.0.0

This commit is contained in:
Tobe O 2018-09-11 18:11:44 -04:00
parent 2962142306
commit 8617598dd2
7 changed files with 17 additions and 21 deletions

View file

@ -1,7 +1,8 @@
# 2.0.0-beta
# 2.0.0
* Made `AuthStrategy` generic.
* `AngelAuth.strategies` is now a `Map<String, AuthStrategy<User>>`.
* Removed `AuthStrategy.canLogout`.
* Made `AngelAuthTokenCallback` generic.
# 2.0.0-alpha
* Depend on Dart 2 and Angel 2.

View file

@ -3,7 +3,6 @@ library angel_auth;
export 'src/middleware/require_auth.dart';
export 'src/strategies/strategies.dart';
export 'src/auth_token.dart';
export 'src/defs.dart';
export 'src/options.dart';
export 'src/plugin.dart';
export 'src/popup_page.dart';

View file

@ -1,7 +0,0 @@
import 'dart:async';
/// Serializes a user to the session.
typedef FutureOr UserSerializer<T>(T user);
/// Deserializes a user from the session.
typedef FutureOr<T> UserDeserializer<T>(userId);

View file

@ -1,15 +1,17 @@
import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
import 'auth_token.dart';
typedef AngelAuthCallback(
typedef FutureOr AngelAuthCallback(
RequestContext req, ResponseContext res, String token);
typedef AngelAuthTokenCallback(
RequestContext req, ResponseContext res, AuthToken token, user);
typedef FutureOr AngelAuthTokenCallback<User>(
RequestContext req, ResponseContext res, AuthToken token, User user);
class AngelAuthOptions {
class AngelAuthOptions<User> {
AngelAuthCallback callback;
AngelAuthTokenCallback tokenCallback;
AngelAuthTokenCallback<User> tokenCallback;
String successRedirect;
String failureRedirect;

View file

@ -4,7 +4,6 @@ import 'dart:math' as Math;
import 'package:angel_framework/angel_framework.dart';
import 'package:crypto/crypto.dart';
import 'auth_token.dart';
import 'defs.dart';
import 'options.dart';
import 'strategy.dart';
@ -49,10 +48,10 @@ class AngelAuth<User> {
Map<String, AuthStrategy<User>> strategies = {};
/// Serializes a user into a unique identifier associated only with one identity.
UserSerializer<User> serializer;
FutureOr Function(User) serializer;
/// Deserializes a unique identifier into its associated identity. In most cases, this is a user object or model instance.
UserDeserializer<User> deserializer;
FutureOr<User> Function(Object) deserializer;
/// Fires the result of [deserializer] whenever a user signs in to the application.
Stream<User> get onLogin => _onLogin.stream;
@ -75,6 +74,8 @@ class AngelAuth<User> {
/// `jwtLifeSpan` - should be in *milliseconds*.
AngelAuth(
{String jwtKey,
this.serializer,
this.deserializer,
num jwtLifeSpan,
this.allowCookie: true,
this.allowTokenInQuery: true,
@ -250,7 +251,7 @@ class AngelAuth<User> {
/// or a `401 Not Authenticated` is thrown, if it is the last one.
///
/// Any other result is considered an authenticated user, and terminates the loop.
RequestHandler authenticate(type, [AngelAuthOptions options]) {
RequestHandler authenticate(type, [AngelAuthOptions<User> options]) {
return (RequestContext req, ResponseContext res) async {
List<String> names = [];
var arr = type is Iterable ? type.toList() : [type];
@ -356,7 +357,7 @@ class AngelAuth<User> {
}
/// Log an authenticated user out.
RequestHandler logout([AngelAuthOptions options]) {
RequestHandler logout([AngelAuthOptions<User> options]) {
return (RequestContext req, ResponseContext res) async {
if (req.container.has<User>()) {
var user = req.container.make<User>();

View file

@ -1,6 +1,6 @@
name: angel_auth
description: A complete authentication plugin for Angel.
version: 2.0.0-beta
version: 2.0.0
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_auth
environment:

View file

@ -9,7 +9,7 @@ import 'package:test/test.dart';
final AngelAuth<Map<String, String>> auth =
new AngelAuth<Map<String, String>>();
var headers = <String, String>{'accept': 'application/json'};
AngelAuthOptions localOpts = new AngelAuthOptions(
var localOpts = new AngelAuthOptions<Map<String, String>>(
failureRedirect: '/failure', successRedirect: '/success');
Map<String, String> sampleUser = {'hello': 'world'};