frog_auth 0.0.1 copy "frog_auth: ^0.0.1" to clipboard
frog_auth: ^0.0.1 copied to clipboard

Authentication for Dart Frog apps

Frog Auth #

Authentication tools for Dart Frog apps.

Installation #

Pub Version

dart pub add frog_auth

Usage #

Basic Authentication #

To support Basic authentication, simply add the basicAuthentication middleware:

Handler middleware(Handler handler) {
    return handler.use(
        basicAuthentication(
            retrieveUser: (username, password) async {
                // TODO Retrieve user by username/password
            },
        ),
    );
}

The retrieveUser callback should be used to lookup the user using the given username and password. If no user is found with the given credentials, you should return null.

If a non-null user is returned by the retrieveUser callback, it will be provided to the current request context and can be retrieved using context.read().

retrieveUser can return an object of any type extending Object, so should be flexible enough to work with any database system.

Bearer Authentication #

To support Bearer authentication, simply add the bearerAuthentication middleware:

Handler middleware(Handler handler) {
    return handler.use(
        bearerAuthentication(
            retrieveUser: (token) async {
                // TODO Retrieve user by token
            },
        ),
    );
}

The retrieveUser callback should be used to lookup the user using the given token. If no user is found with the given token, you should return null.

If a non-null user is returned by the retrieveUser callback, it will be provided to the current request context and can be retrieved using context.read().

retrieveUser can return an object of any type extending Object, so should be flexible enough to work with any database system.

7
likes
125
pub points
0%
popularity

Publisher

unverified uploader

Authentication for Dart Frog apps

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dart_frog

More

Packages that depend on frog_auth