dart2_constant
This commit is contained in:
parent
8e090e0c62
commit
aca5489e8d
7 changed files with 24 additions and 18 deletions
|
@ -3,6 +3,7 @@
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
</content>
|
</content>
|
||||||
|
|
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# 1.0.1
|
||||||
|
* Dart2 updates + backwards compatibility assurance.
|
||||||
|
* Added support for the `device_code` grant: https://github.com/angel-dart/oauth2/issues/7
|
|
@ -1,6 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
|
import 'package:dart2_constant/convert.dart';
|
||||||
import 'exception.dart';
|
import 'exception.dart';
|
||||||
import 'response.dart';
|
import 'response.dart';
|
||||||
import 'token_type.dart';
|
import 'token_type.dart';
|
||||||
|
@ -296,7 +296,7 @@ abstract class AuthorizationServer<Client, User> {
|
||||||
|
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
match = _rgxBasicAuth
|
match = _rgxBasicAuth
|
||||||
.firstMatch(new String.fromCharCodes(BASE64URL.decode(match[1])));
|
.firstMatch(new String.fromCharCodes(base64Url.decode(match[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
|
|
|
@ -4,9 +4,10 @@ description: angel_auth strategy for in-house OAuth2 login.
|
||||||
homepage: https://github.com/angel-dart/oauth2.git
|
homepage: https://github.com/angel-dart/oauth2.git
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=1.19.0"
|
sdk: ">=1.8.0 <3.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: ^1.0.0-dev
|
angel_framework: ^1.0.0-dev
|
||||||
|
dart2_constant: ^1.0.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
angel_test: ^1.1.0-alpha
|
angel_test: ^1.1.0-alpha
|
||||||
oauth2: ^1.0.0
|
oauth2: ^1.0.0
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
import 'package:angel_oauth2/angel_oauth2.dart';
|
import 'package:angel_oauth2/angel_oauth2.dart';
|
||||||
import 'package:angel_test/angel_test.dart';
|
import 'package:angel_test/angel_test.dart';
|
||||||
|
import 'package:dart2_constant/convert.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:oauth2/oauth2.dart' as oauth2;
|
import 'package:oauth2/oauth2.dart' as oauth2;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
@ -34,8 +34,9 @@ main() {
|
||||||
if (rec.stackTrace != null) print(rec.stackTrace);
|
if (rec.stackTrace != null) print(rec.stackTrace);
|
||||||
});
|
});
|
||||||
|
|
||||||
var http = await app.startServer();
|
var http = new AngelHttp(app);
|
||||||
var url = 'http://${http.address.address}:${http.port}';
|
var s = await http.startServer();
|
||||||
|
var url = 'http://${s.address.address}:${s.port}';
|
||||||
authorizationEndpoint = Uri.parse('$url/oauth2/authorize');
|
authorizationEndpoint = Uri.parse('$url/oauth2/authorize');
|
||||||
tokenEndpoint = Uri.parse('$url/oauth2/token');
|
tokenEndpoint = Uri.parse('$url/oauth2/token');
|
||||||
redirectUri = Uri.parse('http://foo.bar/baz');
|
redirectUri = Uri.parse('http://foo.bar/baz');
|
||||||
|
@ -63,7 +64,7 @@ main() {
|
||||||
print('Body: ${response.body}');
|
print('Body: ${response.body}');
|
||||||
expect(
|
expect(
|
||||||
response.body,
|
response.body,
|
||||||
JSON.encode(
|
json.encode(
|
||||||
'Hello ${pseudoApplication.id}:${pseudoApplication.secret}'));
|
'Hello ${pseudoApplication.id}:${pseudoApplication.secret}'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ main() {
|
||||||
var url = grant.getAuthorizationUrl(redirectUri, state: 'goodbye');
|
var url = grant.getAuthorizationUrl(redirectUri, state: 'goodbye');
|
||||||
var response = await testClient.client.get(url);
|
var response = await testClient.client.get(url);
|
||||||
print('Body: ${response.body}');
|
print('Body: ${response.body}');
|
||||||
expect(JSON.decode(response.body)['state'], 'goodbye');
|
expect(json.decode(response.body)['state'], 'goodbye');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sends auth code', () async {
|
test('sends auth code', () async {
|
||||||
|
@ -81,7 +82,7 @@ main() {
|
||||||
var response = await testClient.client.get(url);
|
var response = await testClient.client.get(url);
|
||||||
print('Body: ${response.body}');
|
print('Body: ${response.body}');
|
||||||
expect(
|
expect(
|
||||||
JSON.decode(response.body),
|
json.decode(response.body),
|
||||||
allOf(
|
allOf(
|
||||||
isMap,
|
isMap,
|
||||||
predicate((Map m) => m.containsKey('code'), 'contains "code"'),
|
predicate((Map m) => m.containsKey('code'), 'contains "code"'),
|
||||||
|
@ -95,7 +96,7 @@ main() {
|
||||||
var response = await testClient.client.get(url);
|
var response = await testClient.client.get(url);
|
||||||
print('Body: ${response.body}');
|
print('Body: ${response.body}');
|
||||||
|
|
||||||
var authCode = JSON.decode(response.body)['code'];
|
var authCode = json.decode(response.body)['code'];
|
||||||
var client = await grant.handleAuthorizationCode(authCode);
|
var client = await grant.handleAuthorizationCode(authCode);
|
||||||
expect(client.credentials.accessToken, authCode + '_access');
|
expect(client.credentials.accessToken, authCode + '_access');
|
||||||
});
|
});
|
||||||
|
@ -106,7 +107,7 @@ main() {
|
||||||
var response = await testClient.client.get(url);
|
var response = await testClient.client.get(url);
|
||||||
print('Body: ${response.body}');
|
print('Body: ${response.body}');
|
||||||
|
|
||||||
var authCode = JSON.decode(response.body)['code'];
|
var authCode = json.decode(response.body)['code'];
|
||||||
var client = await grant.handleAuthorizationCode(authCode);
|
var client = await grant.handleAuthorizationCode(authCode);
|
||||||
expect(client.credentials.accessToken, authCode + '_access');
|
expect(client.credentials.accessToken, authCode + '_access');
|
||||||
expect(client.credentials.canRefresh, isTrue);
|
expect(client.credentials.canRefresh, isTrue);
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
import 'package:angel_test/angel_test.dart';
|
import 'package:angel_test/angel_test.dart';
|
||||||
import 'package:angel_oauth2/angel_oauth2.dart';
|
import 'package:angel_oauth2/angel_oauth2.dart';
|
||||||
import 'package:angel_validate/angel_validate.dart';
|
import 'package:angel_validate/angel_validate.dart';
|
||||||
|
import 'package:dart2_constant/convert.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ main() {
|
||||||
var response = await client.post(
|
var response = await client.post(
|
||||||
'/oauth2/token',
|
'/oauth2/token',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Basic ' + BASE64URL.encode('foo:bar'.codeUnits),
|
'Authorization': 'Basic ' + base64Url.encode('foo:bar'.codeUnits),
|
||||||
},
|
},
|
||||||
body: {
|
body: {
|
||||||
'grant_type': 'client_credentials',
|
'grant_type': 'client_credentials',
|
||||||
|
@ -45,7 +44,7 @@ main() {
|
||||||
|
|
||||||
expect(response, allOf(
|
expect(response, allOf(
|
||||||
hasStatus(200),
|
hasStatus(200),
|
||||||
hasContentType(ContentType.JSON),
|
hasContentType('application/json'),
|
||||||
hasValidBody(new Validator({
|
hasValidBody(new Validator({
|
||||||
'token_type': equals('bearer'),
|
'token_type': equals('bearer'),
|
||||||
'access_token': equals('foo'),
|
'access_token': equals('foo'),
|
||||||
|
@ -57,7 +56,7 @@ main() {
|
||||||
var response = await client.post(
|
var response = await client.post(
|
||||||
'/oauth2/token',
|
'/oauth2/token',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Basic ' + BASE64URL.encode('fooa:bar'.codeUnits),
|
'Authorization': 'Basic ' + base64Url.encode('fooa:bar'.codeUnits),
|
||||||
},
|
},
|
||||||
body: {
|
body: {
|
||||||
'grant_type': 'client_credentials',
|
'grant_type': 'client_credentials',
|
||||||
|
@ -72,7 +71,7 @@ main() {
|
||||||
var response = await client.post(
|
var response = await client.post(
|
||||||
'/oauth2/token',
|
'/oauth2/token',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Basic ' + BASE64URL.encode('foo:bara'.codeUnits),
|
'Authorization': 'Basic ' + base64Url.encode('foo:bara'.codeUnits),
|
||||||
},
|
},
|
||||||
body: {
|
body: {
|
||||||
'grant_type': 'client_credentials',
|
'grant_type': 'client_credentials',
|
||||||
|
|
|
@ -26,7 +26,8 @@ main() {
|
||||||
|
|
||||||
app.logger = new Logger('password_test')..onRecord.listen(print);
|
app.logger = new Logger('password_test')..onRecord.listen(print);
|
||||||
|
|
||||||
var server = await app.startServer();
|
var http = new AngelHttp(app);
|
||||||
|
var server = await http.startServer();
|
||||||
var url = 'http://${server.address.address}:${server.port}';
|
var url = 'http://${server.address.address}:${server.port}';
|
||||||
tokenEndpoint = Uri.parse('$url/oauth2/token');
|
tokenEndpoint = Uri.parse('$url/oauth2/token');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue