npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pixaera-auth-client

v1.7.16

Published

This package enables a service to connect to Pixaera's auth provider, enabling users with account on Pixaera to log in other systems with same user.

Downloads

70

Readme

Pixaera Auth Client

This package enables a service to connect to Pixaera's auth provider, enabling users with account on Pixaera to log in other systems with same user.

Install

npm install pixaera-auth-client

Configuration

This package runs on Node.js Express.js and requires that cookie-parser is configured.

Also, the following environment variables are required:

PIXAERA_AUTH_CLIENT_ID=[ID Issued by Pixaera]
PIXAERA_AUTH_CLIENT_SECRET=[Secret Issued by Pixaera]
PIXAERA_AUTH_CRYPT_SECRET=[A secret of your choice, must be a long string]
PIXAERA_AUTH_REDIRECT_URI=[URL with Authentication Callback]
PIXAERA_AUTH_AFTER_LOGIN_PAGE=[URL to Redirect once credentials are set]
PIXAERA_AUTH_SCOPE=[Scopes to be allowed by user] - Example: 'openid email roles' (Default is 'openid')
PIXAERA_AUTH_CALLBACK_NO_REDIRECT=If this variable is true, the redirect after callback must be made manually (avoids CORS issues)

If you want to test an application, you can use our SANDBOX Mode. To do so, just set the environment variable PIXAERA_AUTH_SANDBOX to true.

Example

In the example below, the first route is being protected by authentication. If the user is not authenticated, or doesn't have the permission "permission_test" inside one of its roles, The authMiddleware will return error "Access is Forbidden".

To authenticate the user, you must call pixaeraAuthClient.getAuthUrl and redirect the user to the resulting URL. The URL will already have the redirect back to the client, on 'https://[YOUR_DOMAIN]/auth_callback' (PIXAERA_AUTH_REDIRECT_URI). Then, after callback was successfull, user will be redirected to 'https://[YOUR_DOMAIN]' (PIXAERA_AUTH_AFTER_LOGIN_PAGE)

const pixaeraAuthClient = require('pixaera-auth-client');

// Retrieves protected content if user is authenticated, else calls next(err)
router.get('/', pixaeraAuthClient.authMiddleware('permission_test'), function (req, res, next) {
  // SOURCE BEING PROTECTED BY AUTHENTICATION
});

// Returns a url to authenticate {url: URL}
router.get('/auth_url', pixaeraAuthClient.getAuthUrl);

// Authenticates user after callback from Auth Server 
// (Will redirect to PIXAERA_AUTH_AFTER_LOGIN_PAGE afterwards)
router.get('/auth_callback', pixaeraAuthClient.authCallback);

Besides these methods, pixara-auth-client also has a "me" function, to return user info (the info depends on the scope authorized by the user during login).

// Returns user info, according to scope
router.get('/me', pixaeraAuthClient.me);

a logout function

// Revokes user's tokens
router.get('/logout', pixaeraAuthClient.logout);

and a function to check user's permissions

// Check permission of user (returns status 204 if user has permission, 
// 403 if user is forbidden)
router.get("/permission/:permission", pixaeraAuthClient.permission);