diff --git a/README.md b/README.md index 43233938..02700037 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # angel_auth -[![version 1.1.0-dev+18](https://img.shields.io/badge/version-1.1.0--dev+18-red.svg)](https://pub.dartlang.org/packages/angel_auth) +[![version 1.0.0](https://img.shields.io/badge/version-1.0.0-brightgreen.svg)](https://pub.dartlang.org/packages/angel_auth) ![build status](https://travis-ci.org/angel-dart/auth.svg?branch=master) A complete authentication plugin for Angel. Inspired by Passport. @@ -10,3 +10,13 @@ A complete authentication plugin for Angel. Inspired by Passport. # Supported Strategies * Local (with and without Basic Auth) + +# Default Authentication Callback +A frequent use case within SPA's is opening OAuth login endpoints in a separate window. +[`angel_client`](https://github.com/angel-dart/client) +provides a facility for this, which works perfectly with the default callback provided +in this package. + +```dart +app.authenticate('facebook', new AngelAuthOptions(callback: confirmPopupAuthentication())); +``` diff --git a/lib/angel_auth.dart b/lib/angel_auth.dart index 984fcb44..bd2e0a8e 100644 --- a/lib/angel_auth.dart +++ b/lib/angel_auth.dart @@ -6,4 +6,5 @@ export 'src/auth_token.dart'; export 'src/defs.dart'; export 'src/options.dart'; export 'src/plugin.dart'; +export 'src/popup_page.dart'; export 'src/strategy.dart'; diff --git a/lib/src/popup_page.dart b/lib/src/popup_page.dart new file mode 100644 index 00000000..88ddbe32 --- /dev/null +++ b/lib/src/popup_page.dart @@ -0,0 +1,31 @@ +import 'dart:io'; +import 'package:angel_framework/angel_framework.dart'; +import 'options.dart'; + +/// Displays a default callback page to confirm authentication via popups. +AngelAuthCallback confirmPopupAuthentication({String eventName: 'token'}) { + return (req, ResponseContext res, String jwt) async { + res + ..contentType = ContentType.HTML + ..write(''' + + + + + Authentication Success + + + +

Authentication Success

+

+ Now logging you in... If you continue to see this page, you may need to enable JavaScript. +

+ + + '''); + return false; + }; +} diff --git a/pubspec.yaml b/pubspec.yaml index 14155f0e..08920fca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_auth description: A complete authentication plugin for Angel. -version: 1.0.0-dev+18 +version: 1.0.0 author: Tobe O homepage: https://github.com/angel-dart/angel_auth environment: