diff --git a/.gitignore b/.gitignore index 1c74d020..9df86415 100644 --- a/.gitignore +++ b/.gitignore @@ -110,3 +110,7 @@ pubspec.lock # Don't commit pubspec lock file # (Library packages only! Remove pattern if developing an application package) + +packages +**/packages +bin/packages \ No newline at end of file diff --git a/.idea/angel.iml b/.idea/angel.iml new file mode 100644 index 00000000..dfd40b93 --- /dev/null +++ b/.idea/angel.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000..97626ba4 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..bfb1eabb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..b0343846 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/bin/packages b/bin/packages deleted file mode 120000 index a16c4050..00000000 --- a/bin/packages +++ /dev/null @@ -1 +0,0 @@ -../packages \ No newline at end of file diff --git a/lib/src/config/config.dart b/lib/src/config/config.dart index 70187e13..7dde821b 100644 --- a/lib/src/config/config.dart +++ b/lib/src/config/config.dart @@ -2,31 +2,12 @@ library angel.config; import 'dart:io'; -import 'package:angel_auth/angel_auth.dart'; import 'package:angel_configuration/angel_configuration.dart'; import 'package:angel_framework/angel_framework.dart'; import 'package:angel_mustache/angel_mustache.dart'; /// This is a perfect place to include configuration and load plug-ins. configureServer(Angel app) async { - AngelAuthOptions localOpts = new AngelAuthOptions( - failureRedirect: '/failure', successRedirect: '/success'); - Map sampleUser = {'hello': 'world'}; - - verifier(username, password) async { - if (username == 'username' && password == 'password') { - return sampleUser; - } else - return false; - } - - wireAuth(Angel app) async { - Auth.serializer = (user) async => 1337; - Auth.deserializer = (id) async => sampleUser; - - Auth.strategies.add(new LocalAuthStrategy(verifier)); - await app.configure(AngelAuth); - } await app.configure(loadConfigurationFile()); await app.configure(mustache(new Directory('views'))); } diff --git a/lib/src/routes/controllers/auth.dart b/lib/src/routes/controllers/auth.dart new file mode 100644 index 00000000..53ff0179 --- /dev/null +++ b/lib/src/routes/controllers/auth.dart @@ -0,0 +1,19 @@ +part of angel.routes.controllers; + +@Expose("/auth") +class AuthController extends Controller { + @override + call(Angel app) async { + app.registerMiddleware("auth", (req, res) async { + if (req.session['userId'] == null) + throw new AngelHttpException.Forbidden(); + + return true; + }); + } + + @Expose("/login", method: "POST") + login(RequestContext req) async { + // Include log-in logic here... + } +} diff --git a/lib/src/routes/controllers/controllers.dart b/lib/src/routes/controllers/controllers.dart new file mode 100644 index 00000000..15f395f7 --- /dev/null +++ b/lib/src/routes/controllers/controllers.dart @@ -0,0 +1,9 @@ +library angel.routes.controllers; + +import 'package:angel_auth/angel_auth.dart'; +import 'package:angel_framework/angel_framework.dart'; +part 'auth.dart'; + +configureServer(Angel app) async { + await app.configure(new AuthController()); +} diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index 2801c48a..954eee24 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.dart @@ -3,6 +3,7 @@ library angel.routes; import 'package:angel_framework/angel_framework.dart'; import 'package:angel_static/angel_static.dart'; +import 'controllers/controllers.dart' as Controllers; configureBefore(Angel app) async {} diff --git a/pubspec.yaml b/pubspec.yaml index 07fce40e..a2d005f3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,9 @@ name: angel description: An easily-extensible web server framework in Dart. -version: 0.0.0-dev.0 +version: 1.0.0-dev author: thosakwe homepage: https://github.com/angel-dart/angel +publish_to: none dependencies: angel_auth: ">=1.0.0-dev <2.0.0" angel_configuration: ">=1.0.0-dev <2.0.0" diff --git a/web/packages b/web/packages deleted file mode 120000 index a16c4050..00000000 --- a/web/packages +++ /dev/null @@ -1 +0,0 @@ -../packages \ No newline at end of file