flh

flux-login-helper

Flux login helper for OIDC auth code flow.

Showing:

Popularity

Downloads/wk

3

Maintenance

No Maintenance Data Available

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

flux-login-helper

Helpers for doing the OIDC Authentication Code flow with Flux.io.

Example

var FluxSdk = require("flux-sdk-node");
var LoginHelper = require("flux-login-helper");

var sdk = new FluxSdk("your_client_id", {
    clientSecret: "your_client_secret",
    redirectUri: "https://your.app/auth_callback",
};

/* Somewhere in your app... */
function userIsUnauthedHandler(request, response) {
    var helper = new LoginHelper(sdk);
    /* Redirect the user to Flux for authentication. */
    response.writeHead(303, {"Location": helper.getAuthorizeUrl()});
    response.end();
}

/* Setup the authentication callback route. */
app.addRoute("/auth_callback", "GET", function(request, response) {
    LoginHelper.OIDCResponseHandler(request, response)
    .then(function(credentials) {
        /* do something e.g. get a Flux user object */
        var user = sdk.getUser(credentials);
    });
});

Usage

Each instance of LoginHelper is good for one authentication flow (request and response). The static method LoginHelper.OIDCResponseHandler keeps a registry of LoginHelper instances so that the authentication callback is paired with the correct initial request.

Methods

Static methods:

  • OIDCResponseHandler(request, response) -> Promise(credentials): Use this at the /auth_callback route (or equivalent) in your app to get the authed user's credentials.
  • setLogLevel(level): Sets the log level of flux-login-helper and all its dependencies.

Instance methods:

  • #getAuthorizeUrl(): Get a Flux authorization url to which you should redirect the unauthed user.
  • #exchangeCredentials(): Given a query object containing the parameters of the auth code response from Flux, makes the token request. You should not need to call this directly.
  • #loginLocal() -> Promise(credentials): Locally runs a complete auth code flow login. Useful for terminal applications where you expect only one user.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial