Updated auth
This commit is contained in:
parent
ef0e625707
commit
e79826bad0
6 changed files with 28 additions and 19 deletions
|
@ -12,7 +12,7 @@
|
|||
* Added merge_map and migrated to 2.0.0 (6/6 tests passed)
|
||||
* Added mock_request and migrated to 2.0.0 (0/0 tests)
|
||||
* Migrated angel_framework to 4.0.0 (149/150 tests passed)
|
||||
* Migrated angel_auth to 4.0.0 (23/30 tests passed)
|
||||
* Migrated angel_auth to 4.0.0 (25/30 tests passed)
|
||||
* Migrated angel_configuration to 4.0.0 (6/8 testspassed)
|
||||
* Migrated angel_validate to 4.0.0 (6/7 tests passed)
|
||||
* Migrated json_god to 4.0.0 (13/13 tests passed)
|
||||
|
@ -40,6 +40,8 @@
|
|||
* Migrated angel_orm_test to 3.0.0 (0/0 tests passed)
|
||||
* Migrated angel_orm_postgres to 3.0.0 (51/54 tests passed)
|
||||
* Create orm-sdk-2.12.x boilerplate (in progress) <= Milestone 2
|
||||
* Migrate angel_cache
|
||||
* Migrate angel_cors
|
||||
|
||||
# 3.0.0 (Non NNBD)
|
||||
* Changed Dart SDK requirements for all packages to ">=2.10.0 <3.0.0"
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# 4.0.2
|
||||
* Added MirrorsReflector to test cases
|
||||
|
||||
# 4.0.1
|
||||
* Updated README
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# angel3_auth
|
||||
[![version](https://img.shields.io/badge/pub-v4.0.1-brightgreen)](https://pub.dartlang.org/packages/angel3_auth)
|
||||
[![version](https://img.shields.io/badge/pub-v4.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_auth)
|
||||
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
||||
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
name: angel3_auth
|
||||
description: A complete authentication plugin for Angel. Includes support for stateless JWT tokens, Basic Auth, and more.
|
||||
version: 4.0.1
|
||||
version: 4.0.2
|
||||
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/auth
|
||||
publish_to: none
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_framework: ^4.0.0
|
||||
angel3_framework: #^4.0.0
|
||||
path: ../framework
|
||||
charcode: ^1.2.0
|
||||
collection: ^1.15.0
|
||||
crypto: ^3.0.0
|
||||
|
@ -13,6 +15,7 @@ dependencies:
|
|||
meta: ^1.3.0
|
||||
quiver: ^3.0.0
|
||||
dev_dependencies:
|
||||
angel3_container: ^3.0.0
|
||||
http: ^0.13.1
|
||||
io: ^1.0.0
|
||||
logging: ^1.0.0
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:io';
|
||||
import 'package:angel3_auth/angel3_auth.dart';
|
||||
import 'package:angel3_container/mirrors.dart';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_framework/http.dart';
|
||||
import 'dart:convert';
|
||||
|
@ -36,14 +37,14 @@ class User extends Model {
|
|||
void main() {
|
||||
late Angel app;
|
||||
late AngelHttp angelHttp;
|
||||
AngelAuth<User?> auth;
|
||||
AngelAuth<User> auth;
|
||||
http.Client? client;
|
||||
HttpServer server;
|
||||
String? url;
|
||||
|
||||
setUp(() async {
|
||||
hierarchicalLoggingEnabled = true;
|
||||
app = Angel();
|
||||
app = Angel(reflector: MirrorsReflector());
|
||||
angelHttp = AngelHttp(app);
|
||||
app.use('/users', MapService());
|
||||
|
||||
|
@ -71,8 +72,8 @@ void main() {
|
|||
.findService('users')!
|
||||
.create({'username': 'jdoe1', 'password': 'password'});
|
||||
|
||||
auth = AngelAuth<User?>();
|
||||
auth.serializer = (u) => u!.id;
|
||||
auth = AngelAuth<User>();
|
||||
auth.serializer = (u) => u.id;
|
||||
auth.deserializer =
|
||||
(id) async => await app.findService('users')!.read(id) as User;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ Future wireAuth(Angel app) async {
|
|||
void main() async {
|
||||
Angel app;
|
||||
late AngelHttp angelHttp;
|
||||
http.Client? client;
|
||||
late http.Client client;
|
||||
String? url;
|
||||
String? basicAuthUrl;
|
||||
|
||||
|
@ -66,13 +66,13 @@ void main() async {
|
|||
|
||||
tearDown(() async {
|
||||
await angelHttp.close();
|
||||
client = null;
|
||||
//client = null;
|
||||
url = null;
|
||||
basicAuthUrl = null;
|
||||
});
|
||||
|
||||
test('can use "auth" as middleware', () async {
|
||||
var response = await client!.get(Uri.parse('$url/success'),
|
||||
var response = await client.get(Uri.parse('$url/success'),
|
||||
headers: {'Accept': 'application/json'});
|
||||
print(response.body);
|
||||
expect(response.statusCode, equals(403));
|
||||
|
@ -80,7 +80,7 @@ void main() async {
|
|||
|
||||
test('successRedirect', () async {
|
||||
var postData = {'username': 'username', 'password': 'password'};
|
||||
var response = await client!.post(Uri.parse('$url/login'),
|
||||
var response = await client.post(Uri.parse('$url/login'),
|
||||
body: json.encode(postData),
|
||||
headers: {'content-type': 'application/json'});
|
||||
expect(response.statusCode, equals(302));
|
||||
|
@ -89,7 +89,7 @@ void main() async {
|
|||
|
||||
test('failureRedirect', () async {
|
||||
var postData = {'username': 'password', 'password': 'username'};
|
||||
var response = await client!.post(Uri.parse('$url/login'),
|
||||
var response = await client.post(Uri.parse('$url/login'),
|
||||
body: json.encode(postData),
|
||||
headers: {'content-type': 'application/json'});
|
||||
print('Login response: ${response.body}');
|
||||
|
@ -99,13 +99,13 @@ void main() async {
|
|||
|
||||
test('allow basic', () async {
|
||||
var authString = base64.encode('username:password'.runes.toList());
|
||||
var response = await client!.get(Uri.parse('$url/hello'),
|
||||
var response = await client.get(Uri.parse('$url/hello'),
|
||||
headers: {'authorization': 'Basic $authString'});
|
||||
expect(response.body, equals('"Woo auth"'));
|
||||
});
|
||||
|
||||
test('allow basic via URL encoding', () async {
|
||||
var response = await client!.get(Uri.parse('$basicAuthUrl/hello'));
|
||||
var response = await client.get(Uri.parse('$basicAuthUrl/hello'));
|
||||
expect(response.body, equals('"Woo auth"'));
|
||||
});
|
||||
|
||||
|
@ -113,13 +113,13 @@ void main() async {
|
|||
auth.strategies.clear();
|
||||
auth.strategies['local'] =
|
||||
LocalAuthStrategy(verifier, forceBasic: true, realm: 'test');
|
||||
var response = await client?.get(Uri.parse('$url/hello'), headers: {
|
||||
var response = await client.get(Uri.parse('$url/hello'), headers: {
|
||||
'accept': 'application/json',
|
||||
'content-type': 'application/json'
|
||||
});
|
||||
print('Header = ${response?.headers}');
|
||||
print('Body <${response?.body}>');
|
||||
var head = response?.headers['www-authenticate'];
|
||||
print('Header = ${response.headers}');
|
||||
print('Body <${response.body}>');
|
||||
var head = response.headers['www-authenticate'];
|
||||
expect(head, equals('Basic realm="test"'));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue