Updated logo
This commit is contained in:
parent
c29c7b7049
commit
799f94bb60
23 changed files with 268 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Angel3 Framework
|
# Angel3 Framework
|
||||||
|
|
||||||
[![Angel3 Framework](./logo3.png)](https://github.com/dukefirehawk/angel)
|
[![Angel3 Framework](./angel3_logo.svg)](https://github.com/dukefirehawk/angel)
|
||||||
|
|
||||||
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_framework?include_prereleases)
|
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_framework?include_prereleases)
|
||||||
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
||||||
|
|
148
angel3_logo.svg
Normal file
148
angel3_logo.svg
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="128"
|
||||||
|
height="128"
|
||||||
|
viewBox="0 0 128 128"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1"
|
||||||
|
inkscape:version="1.3 (0e150ed, 2023-07-21)"
|
||||||
|
sodipodi:docname="angel3_logo128.svg"
|
||||||
|
inkscape:export-filename="logo_icon_128.png"
|
||||||
|
inkscape:export-xdpi="96"
|
||||||
|
inkscape:export-ydpi="96"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview1"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:zoom="1.5862247"
|
||||||
|
inkscape:cx="58.314563"
|
||||||
|
inkscape:cy="90.466376"
|
||||||
|
inkscape:window-width="1312"
|
||||||
|
inkscape:window-height="738"
|
||||||
|
inkscape:window-x="128"
|
||||||
|
inkscape:window-y="89"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="layer1">
|
||||||
|
<inkscape:grid
|
||||||
|
id="grid1"
|
||||||
|
units="px"
|
||||||
|
originx="0"
|
||||||
|
originy="0"
|
||||||
|
spacingx="1"
|
||||||
|
spacingy="1"
|
||||||
|
empcolor="#0099e5"
|
||||||
|
empopacity="0.30196078"
|
||||||
|
color="#0099e5"
|
||||||
|
opacity="0.14901961"
|
||||||
|
empspacing="5"
|
||||||
|
dotted="false"
|
||||||
|
gridanglex="30"
|
||||||
|
gridanglez="30"
|
||||||
|
visible="true" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<defs
|
||||||
|
id="defs1">
|
||||||
|
<linearGradient
|
||||||
|
id="swatch6">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#d81c1c;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop6" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient15"
|
||||||
|
inkscape:collect="always">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#d81c1c;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop15" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#d81c1c;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop16" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="swatch13"
|
||||||
|
inkscape:swatch="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#d81c1c;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop14" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="swatch7"
|
||||||
|
inkscape:swatch="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#d81c1c;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop7" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#swatch13"
|
||||||
|
id="linearGradient14"
|
||||||
|
x1="76.307388"
|
||||||
|
y1="264.40897"
|
||||||
|
x2="425.84061"
|
||||||
|
y2="264.40897"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient15"
|
||||||
|
id="linearGradient16"
|
||||||
|
x1="185.07693"
|
||||||
|
y1="354.51111"
|
||||||
|
x2="296.18161"
|
||||||
|
y2="354.51111"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
</defs>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:137.557px;font-family:'Comic Sans MS';-inkscape-font-specification:'Comic Sans MS, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;opacity:1;fill:#000000;fill-opacity:1;stroke-width:0.716443"
|
||||||
|
x="-115.63483"
|
||||||
|
y="107.96973"
|
||||||
|
id="text1"
|
||||||
|
transform="matrix(-0.01157892,-1.0160496,0.98407611,-0.01121455,0,0)"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan1"
|
||||||
|
x="-115.63483"
|
||||||
|
y="107.96973"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:137.557px;font-family:'Comic Sans MS';-inkscape-font-specification:'Comic Sans MS, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;stroke-width:0.716443">A</tspan></text>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:74.3369px;font-family:'Comic Sans MS';-inkscape-font-specification:'Comic Sans MS, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;opacity:1;fill:#d81c1c;fill-opacity:1;stroke:#ffffff;stroke-width:0.980329;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
x="-100.58853"
|
||||||
|
y="107.32352"
|
||||||
|
id="text2"
|
||||||
|
transform="matrix(-1.1771598,0.04030269,0.03112649,0.84843667,0,0)"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan2"
|
||||||
|
x="-100.58853"
|
||||||
|
y="107.32352"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:74.3369px;font-family:'Comic Sans MS';-inkscape-font-specification:'Comic Sans MS, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#d81c1c;fill-opacity:1;stroke:#ffffff;stroke-width:0.980329;stroke-dasharray:none;stroke-opacity:1">3</tspan></text>
|
||||||
|
<circle
|
||||||
|
style="fill:#d81c1c;fill-opacity:1;stroke:#ffffff;stroke-width:3.00094488;stroke-dasharray:none"
|
||||||
|
id="path6"
|
||||||
|
cx="25.217106"
|
||||||
|
cy="52.325504"
|
||||||
|
r="3.7825663" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 6 KiB After Width: | Height: | Size: 6 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
BIN
logo3.xcf
BIN
logo3.xcf
Binary file not shown.
BIN
logo_icon_512.png
Normal file
BIN
logo_icon_512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
|
@ -108,6 +108,8 @@ abstract class Driver<
|
||||||
|
|
||||||
/// Handles a single request.
|
/// Handles a single request.
|
||||||
Future handleRawRequest(Request request, Response response) {
|
Future handleRawRequest(Request request, Response response) {
|
||||||
|
app.logger.info('[Server] Called handleRawRequest');
|
||||||
|
|
||||||
return createRequestContext(request, response).then((req) {
|
return createRequestContext(request, response).then((req) {
|
||||||
return createResponseContext(request, response, req).then((res) {
|
return createResponseContext(request, response, req).then((res) {
|
||||||
Future handle() {
|
Future handle() {
|
||||||
|
|
|
@ -20,8 +20,8 @@ In your `pubspec.yaml`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
angel3_framework: ^6.0.0
|
angel3_framework: ^8.0.0
|
||||||
angel3_oauth2: ^6.0.0
|
angel3_oauth2: ^8.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
94
packages/oauth2/example/example1.dart
Normal file
94
packages/oauth2/example/example1.dart
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:angel3_container/mirrors.dart';
|
||||||
|
import 'package:angel3_framework/angel3_framework.dart';
|
||||||
|
import 'package:angel3_oauth2/angel3_oauth2.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
|
import '../test/common.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
Logger.root.level = Level.ALL;
|
||||||
|
Logger.root.onRecord.listen((record) {
|
||||||
|
print(
|
||||||
|
'${record.time} ${record.level.name.padLeft(6, ' ')} [${record.loggerName}] : ${record.message}');
|
||||||
|
if (record.error != null) print(record.error);
|
||||||
|
if (record.stackTrace != null) print(record.stackTrace);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Declae the function
|
||||||
|
void setUp() async {
|
||||||
|
var app = Angel(reflector: MirrorsReflector());
|
||||||
|
var oauth2 = _AuthorizationServer();
|
||||||
|
|
||||||
|
app.group('/oauth2', (router) {
|
||||||
|
router
|
||||||
|
..get('/authorize', oauth2.authorizationEndpoint)
|
||||||
|
..post('/token', oauth2.tokenEndpoint);
|
||||||
|
});
|
||||||
|
|
||||||
|
//app.logger.level = Level.ALL;
|
||||||
|
app.logger = Logger("oauth2")
|
||||||
|
..onRecord.listen((rec) {
|
||||||
|
print(rec);
|
||||||
|
if (rec.error != null) print(rec.error);
|
||||||
|
if (rec.stackTrace != null) print(rec.stackTrace);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.errorHandler = (e, req, res) async {
|
||||||
|
res.json(e.toJson());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AuthorizationServer
|
||||||
|
extends AuthorizationServer<PseudoApplication, PseudoUser> {
|
||||||
|
var logger = Logger('AuthorizationServer');
|
||||||
|
|
||||||
|
@override
|
||||||
|
PseudoApplication? findClient(String? clientId) {
|
||||||
|
return clientId == pseudoApplication.id ? pseudoApplication : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> verifyClient(
|
||||||
|
PseudoApplication client, String? clientSecret) async {
|
||||||
|
return client.secret == clientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<DeviceCodeResponse> requestDeviceCode(PseudoApplication client,
|
||||||
|
Iterable<String> scopes, RequestContext req, ResponseContext res) {
|
||||||
|
return DeviceCodeResponse(
|
||||||
|
'foo',
|
||||||
|
'bar',
|
||||||
|
Uri.parse('https://regiostech.com')
|
||||||
|
.replace(queryParameters: {'scopes': scopes.join(',')}),
|
||||||
|
3600);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<AuthorizationTokenResponse> exchangeDeviceCodeForToken(
|
||||||
|
PseudoApplication client,
|
||||||
|
String? deviceCode,
|
||||||
|
String state,
|
||||||
|
RequestContext req,
|
||||||
|
ResponseContext res) {
|
||||||
|
print("[Server] exchangeDeviceCodeForToken");
|
||||||
|
print("[Server] $deviceCode");
|
||||||
|
print("[Server] $client");
|
||||||
|
|
||||||
|
if (deviceCode == 'brute') {
|
||||||
|
print("[Server] Throws AuthorizationException");
|
||||||
|
|
||||||
|
throw AuthorizationException(ErrorResponse(
|
||||||
|
ErrorResponse.slowDown,
|
||||||
|
'Ho, brother! Ho, whoa, whoa, whoa now! You got too much dip on your chip!',
|
||||||
|
state));
|
||||||
|
}
|
||||||
|
|
||||||
|
return AuthorizationTokenResponse('foo');
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:angel3_framework/angel3_framework.dart';
|
import 'package:angel3_framework/angel3_framework.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
import 'exception.dart';
|
import 'exception.dart';
|
||||||
import 'pkce.dart';
|
import 'pkce.dart';
|
||||||
import 'response.dart';
|
import 'response.dart';
|
||||||
|
@ -51,6 +52,8 @@ Future<Iterable<String>> _getScopes(RequestContext req,
|
||||||
|
|
||||||
/// An OAuth2 authorization server, which issues access tokens to third parties.
|
/// An OAuth2 authorization server, which issues access tokens to third parties.
|
||||||
abstract class AuthorizationServer<Client, User> {
|
abstract class AuthorizationServer<Client, User> {
|
||||||
|
static Logger logger = Logger('AuthorizationServer');
|
||||||
|
|
||||||
const AuthorizationServer();
|
const AuthorizationServer();
|
||||||
|
|
||||||
static const String _internalServerError =
|
static const String _internalServerError =
|
||||||
|
|
|
@ -11,10 +11,11 @@ dependencies:
|
||||||
angel3_http_exception: ^8.0.0
|
angel3_http_exception: ^8.0.0
|
||||||
crypto: ^3.0.1
|
crypto: ^3.0.1
|
||||||
collection: ^1.17.0
|
collection: ^1.17.0
|
||||||
|
logging: ^1.2.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
angel3_validate: ^8.0.0
|
angel3_validate: ^8.0.0
|
||||||
angel3_test: ^8.0.0
|
angel3_test: ^8.0.0
|
||||||
logging: ^1.2.0
|
angel3_container: ^8.0.0
|
||||||
oauth2: ^2.0.0
|
oauth2: ^2.0.0
|
||||||
lints: ^2.1.0
|
lints: ^2.1.0
|
||||||
test: ^1.24.0
|
test: ^1.24.0
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:angel3_container/mirrors.dart';
|
||||||
import 'package:angel3_framework/angel3_framework.dart';
|
import 'package:angel3_framework/angel3_framework.dart';
|
||||||
import 'package:angel3_test/angel3_test.dart';
|
import 'package:angel3_test/angel3_test.dart';
|
||||||
import 'package:angel3_oauth2/angel3_oauth2.dart';
|
import 'package:angel3_oauth2/angel3_oauth2.dart';
|
||||||
|
@ -10,7 +11,7 @@ void main() {
|
||||||
late TestClient client;
|
late TestClient client;
|
||||||
|
|
||||||
setUp(() async {
|
setUp(() async {
|
||||||
var app = Angel();
|
var app = Angel(reflector: MirrorsReflector());
|
||||||
var oauth2 = _AuthorizationServer();
|
var oauth2 = _AuthorizationServer();
|
||||||
|
|
||||||
app.group('/oauth2', (router) {
|
app.group('/oauth2', (router) {
|
||||||
|
@ -19,7 +20,8 @@ void main() {
|
||||||
..post('/token', oauth2.tokenEndpoint);
|
..post('/token', oauth2.tokenEndpoint);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.logger = Logger('angel_oauth2')
|
//app.logger.level = Level.ALL;
|
||||||
|
app.logger = Logger("oauth2")
|
||||||
..onRecord.listen((rec) {
|
..onRecord.listen((rec) {
|
||||||
print(rec);
|
print(rec);
|
||||||
if (rec.error != null) print(rec.error);
|
if (rec.error != null) print(rec.error);
|
||||||
|
@ -113,7 +115,8 @@ void main() {
|
||||||
'device_code': 'brute',
|
'device_code': 'brute',
|
||||||
});
|
});
|
||||||
|
|
||||||
print(response.body);
|
print("[Client] ${response.headers}");
|
||||||
|
print("[Client] ${response.body}");
|
||||||
expect(
|
expect(
|
||||||
response,
|
response,
|
||||||
allOf(
|
allOf(
|
||||||
|
@ -130,6 +133,8 @@ void main() {
|
||||||
|
|
||||||
class _AuthorizationServer
|
class _AuthorizationServer
|
||||||
extends AuthorizationServer<PseudoApplication, PseudoUser> {
|
extends AuthorizationServer<PseudoApplication, PseudoUser> {
|
||||||
|
var logger = Logger('AuthorizationServer');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PseudoApplication? findClient(String? clientId) {
|
PseudoApplication? findClient(String? clientId) {
|
||||||
return clientId == pseudoApplication.id ? pseudoApplication : null;
|
return clientId == pseudoApplication.id ? pseudoApplication : null;
|
||||||
|
@ -159,7 +164,13 @@ class _AuthorizationServer
|
||||||
String state,
|
String state,
|
||||||
RequestContext req,
|
RequestContext req,
|
||||||
ResponseContext res) {
|
ResponseContext res) {
|
||||||
|
print("[Server] exchangeDeviceCodeForToken");
|
||||||
|
print("[Server] $deviceCode");
|
||||||
|
print("[Server] $client");
|
||||||
|
|
||||||
if (deviceCode == 'brute') {
|
if (deviceCode == 'brute') {
|
||||||
|
print("[Server] Throws AuthorizationException");
|
||||||
|
|
||||||
throw AuthorizationException(ErrorResponse(
|
throw AuthorizationException(ErrorResponse(
|
||||||
ErrorResponse.slowDown,
|
ErrorResponse.slowDown,
|
||||||
'Ho, brother! Ho, whoa, whoa, whoa now! You got too much dip on your chip!',
|
'Ho, brother! Ho, whoa, whoa, whoa now! You got too much dip on your chip!',
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
import 'package:angel3_container/mirrors.dart';
|
||||||
import 'package:angel3_framework/angel3_framework.dart';
|
import 'package:angel3_framework/angel3_framework.dart';
|
||||||
import 'package:angel3_framework/http.dart';
|
import 'package:angel3_framework/http.dart';
|
||||||
import 'package:angel3_oauth2/angel3_oauth2.dart';
|
import 'package:angel3_oauth2/angel3_oauth2.dart';
|
||||||
|
@ -14,7 +15,7 @@ void main() {
|
||||||
late TestClient testClient;
|
late TestClient testClient;
|
||||||
|
|
||||||
setUp(() async {
|
setUp(() async {
|
||||||
app = Angel();
|
app = Angel(reflector: MirrorsReflector());
|
||||||
app.container.registerSingleton(AuthCodes());
|
app.container.registerSingleton(AuthCodes());
|
||||||
|
|
||||||
var server = _Server();
|
var server = _Server();
|
||||||
|
|
Loading…
Reference in a new issue