frog_auth

Last updated:

0 purchases

frog_auth Image
frog_auth Images
Add to Cart

Description:

frog auth

Frog Auth #
Authentication tools for Dart Frog apps.
Installation #

dart pub add frog_auth
copied to clipboard
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
},
),
);
}
copied to clipboard
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
},
),
);
}
copied to clipboard
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.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.