jaguar_auth_mongo 1.3.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 65

jaguar_auth_mongo

Jaguar AuthModelManager for MongoDb backend

Usage

User model that implements AuthorizationUser.

class User implements AuthorizationUser {
  String id;

  String username;

  String password;

  User();

  User.make(this.id, this.username, this.password);

  String get authorizationId => id;
}

Mongo model manager to fetch and authenticate the user model.

final MgoUserManager<User> modelManager =
    new MgoUserManager<User>(userMgoSerializer);

Interface containing all the MongoDb and Authorizer interceptor creators.

abstract class BaseApi {
  /// Interceptor creator for authorization
  Authorizer authorizer(Context ctx) => new Authorizer(modelManager);

  /// Interceptor creator to connect to MongoDb
  MongoDb mongoDb(Context ctx) => new MongoDb('mongodb://localhost:27017/test');
}

Authorization routes.

/// This route group contains login and logout routes
@Api(path: '/auth')
@WrapOne(#mongoDb)
class AuthRoutes extends BaseApi {
  @Post(path: '/login')
  Future login(Context ctx) async {
    await BasicAuth.authenticate(ctx, modelManager);
  }

  @Post(path: '/logout')
  Future logout(Context ctx) async {
    // Clear session
    (await ctx.session).clear();
  }
}

Authorized routes.

/// Collection of routes students can also access
@Api(path: '/book')
@Wrap(const [#mongoDb, #authorizer])
class StudentRoutes extends BaseApi {
  @Get(path: '/all')
  Response<String> getAllBooks(Context ctx) {
    List<Map> ret =
        _books.values.map((Book book) => bookSerializer.toMap(book)).toList();
    return Response.json(ret);
  }

  @Get(path: '/:id')
  Response<String> getBook(Context ctx) {
    final String id = ctx.pathParams.get('id');
    final Book book = _books[id];
    return Response.json(bookSerializer.toMap(book));
  }
}

Changelog

0.2.0

  • Streamlined the library

0.0.1

  • Initial version, created by Stagehand

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jaguar_auth_mongo: "^1.3.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jaguar_auth_mongo/jaguar_auth_mongo.dart';
        
Version Uploaded Documentation Archive
1.3.1 Feb 2, 2018 Go to the documentation of jaguar_auth_mongo 1.3.1 Download jaguar_auth_mongo 1.3.1 archive
1.2.6 Jan 13, 2018 Go to the documentation of jaguar_auth_mongo 1.2.6 Download jaguar_auth_mongo 1.2.6 archive
1.1.5 Jan 11, 2018 Go to the documentation of jaguar_auth_mongo 1.1.5 Download jaguar_auth_mongo 1.1.5 archive
0.2.0 Dec 28, 2017 Go to the documentation of jaguar_auth_mongo 0.2.0 Download jaguar_auth_mongo 0.2.0 archive
0.1.2 Jul 9, 2017 Go to the documentation of jaguar_auth_mongo 0.1.2 Download jaguar_auth_mongo 0.1.2 archive
0.1.0 Jul 3, 2017 Go to the documentation of jaguar_auth_mongo 0.1.0 Download jaguar_auth_mongo 0.1.0 archive
0.0.1 May 26, 2017 Go to the documentation of jaguar_auth_mongo 0.0.1 Download jaguar_auth_mongo 0.0.1 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
30 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
65

Platforms

Detected platforms: Flutter, other

Primary library: package:jaguar_auth_mongo/jaguar_auth_mongo.dart with components: io.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use jaguar_auth_mongo.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
auth_header ^0.0.3 0.0.3
jaguar ^1.3.4 1.3.4
jaguar_auth ^1.3.1 1.3.2
jaguar_common ^0.2.2 0.2.2
jaguar_mongo ^1.3.1 1.3.1
jaguar_serializer ^0.5.1 0.5.1 1.0.0-dev1
mongo_dart ^0.3.0 0.3.1
Transitive dependencies
args 1.2.0 1.3.0
async 2.0.3
bson 0.3.0
charcode 1.1.1
collection 1.14.5
connection_pool 0.1.2
convert 2.0.1
crypto 2.0.2+1
fixnum 0.10.6
http_server 0.9.7
intl 0.15.2
logging 0.11.3+1
matcher 0.12.1+4
meta 1.1.2
mime 0.9.6
mongo_dart_query 0.3.0
more 1.8.1
path 1.5.1
pool 1.3.4
quiver_hashcode 1.0.0
quiver_iterables 1.0.1
source_span 1.4.0
stack_trace 1.9.1
string_scanner 1.0.2
typed_data 1.1.5
uuid 0.5.3
yaml 2.1.13
yamlicious 0.0.5
Dev dependencies
jaguar_reflect ^1.3.2
jaguar_serializer_mongo ^0.2.0
test ^0.12.0