jaguar_auth_mongo 1.3.1

  • Readme
  • Changelog
  • Installing
  • 0

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.make(, 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')
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 = 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

Use this package as a library

1. Depend on it

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

  jaguar_auth_mongo: ^1.3.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub 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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 5, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.6.0.
 Because jaguar_auth_mongo depends on jaguar_common >=0.0.2 <2.1.2 which requires SDK version >=1.20.1 <2.0.0 or >=2.0.0-dev.55.0 <2.0.0, version solving failed.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field was unreachable.

Package is getting outdated. (-75.34 points)

The package was last published 91 weeks ago.

The package description is too short. (-17 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and jaguar_auth_mongo.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0