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

@digifi/periodicjs.ext.oauth2server

v11.2.5

Published

An extension that creates an OAuth 2 Server that uses oauth2orize and http-bearer for server-to-server authenication and jwt-token-bearer for mobile/javascript client based authentication.

Downloads

63

Readme

periodicjs.ext.oauth2server Coverage Status Build Status

An extension that creates an OAuth 2 Server that uses oauth2orize and http-bearer for server-to-server authenication and jwt-token-bearer for mobile/javascript client based authentication.

API Documentation

Usage

API Documentation

Usage

Creating an OAuth2 server allows for your periodic application to restrict access to API endpoints for the authorized user or authorized applications.

Step 1: Installing the Extension

Install like any other extension, run npm run install periodicjs.ext.oauth2server from your periodic application directory.

Step 2: Creating Application Clients

Login into Async Admin, in the navigation sidebar Extensions -> OAuth 2 Server -> Clients

Name your new Application Client, a token_id and token_secret will be automatically generated.

Step 3: Obtain an Access Token

Navigate to /api/oauth2/authorize, login in and approve access to your account for your application.

Example: http://localhost:8786/api/oauth2/authorize?client_id=[client token_id]&response_type=code&redirect_uri=[your redirect url, e.g.: http://localhost:3000]

If you approve access, you'll be granted a new authorization code to obtain a new OAUTH 2.0 token.

Then, you'll have to post (using http basic auth with your client token_id and client secret)

  • code: [your authorization code]
  • grant_type: 'authorization_code'
  • redirect_url: [your redirect url]

You'll then recieve an OAUTH Token to make API requests with (With HTTP Bearer Authentication)

For mobile applications using JWT Tokens

Send a get request to /api/jwt/token

With either request headers or a request body containing:

  • username
  • clientid
  • password
  • entitytype (optional if using a different user account model)

You'll then recieve a JWT access_token to make API requests with in either the request body or x-access-token header

Step 4: Make authenticated Requests

  • Add periodic.app.controller.extension.oauth2server.auth.ensureApiAuthenticated middleware before any API route that requires user authentication.
  • Add periodic.app.controller.extension.oauth2server.auth.isClientAuthenticated middleware before any API route that requires application client authentication.

A quick note on security

When implementing an OAuth2 server you MUST make sure to secure your application. This means running all OAuth2 endpoints over HTTPS, this extension also hashes the client secret, authorization code, and access token.

CLI COMMANDS

Create Client

$ cd path/to/application/root
### Using the CLI
$ periodicjs ext periodicjs.ext.oauth2server createClient my-oauth2-client  
$ periodicjs ext periodicjs.ext.oauth2server createclient my-oauth2-client  
$ periodicjs ext periodicjs.ext.oauth2server cc my-oauth2-client  
### Calling Manually
$ node index.js --cli --command --ext --name=periodicjs.ext.oauth2server --task=createClient --args=my-oauth2-client

Configuration

You can configure periodicjs.ext.oauth2server

Default Configuration

{
  settings: {
    defaults: true,
  },
  databases: {
  },
};

Installation

Installing the Extension

Install like any other extension, run npm run install periodicjs.ext.oauth2server from your periodic application root directory and then you would normally run periodicjs addExtension periodicjs.ext.oauth2server but this is handled by the npm post install script.

$ cd path/to/application/root
$ npm run install periodicjs.ext.oauth2server
$ periodicjs addExtension periodicjs.ext.oauth2server //handled by npm post install

Uninstalling the Extension

Run npm run uninstall periodicjs.ext.oauth2server from your periodic application root directory and then you would normally run periodicjs removeExtension periodicjs.ext.oauth2server but this is handled by the npm post uninstall script.

$ cd path/to/application/root
$ npm run uninstall periodicjs.ext.oauth2server
$ periodicjs removeExtension periodicjs.ext.oauth2server //handled by npm post uninstall

Testing

Make sure you have grunt installed

$ npm install -g grunt-cli

Then run grunt test or npm test

$ grunt test && grunt coveralls #or locally $ npm test

For generating documentation

$ grunt doc
$ jsdoc2md commands/**/*.js config/**/*.js controllers/**/*.js  transforms/**/*.js utilities/**/*.js index.js > doc/api.md

Notes

  • Check out https://github.com/typesettin/periodicjs for the full Periodic Documentation
  • Special thanks to scott k smith
  • TODOS
    • reset login attempts