Socket
Socket
Sign inDemoInstall

@lighthouseapps/egg-oauth2

Package Overview
Dependencies
13
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @lighthouseapps/egg-oauth2

> Javascript oauth2 server


Version published
Weekly downloads
12
increased by140%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

oauth2-server

Javascript oauth2 server

Usage

  const {
    EggOAuth2
  } = require('oauth2-server');

  class OAuth2Model {
    constructor(ctx) {
      this.ctx = ctx;
    }

    getClient(id: String, secret: String): Client {}

    getUser(email: String, password: String): User {}

    getAuthorizationCode(code: String): AuthorizationCode {}

    getAccessToken(token: String): AccessToken {}

    getRefreshToken(token: String): RefreshToken {}

    saveAuthorizationCode(code: AuthorizationCode, client: Client, user: User): AuthorizationCode {}

    saveToken(token: Token, client: Client, user: User): Token {}

    revokeAuthorizationCode(code: AuthorizationCode): Boolean {}

    revokeToken(token: Token): Boolean {}
  }

  const oauth2 = new EggOAuth2(OAuth2Model, {
    grants: [
      'password',
      'authorization_code'
    ]
  });

  /*** MODELS ***/
  // Client = { id, secret, grants, ... }
  // User = { id, email, name, ... }
  // AuthorizationCode = { code , expires_at, user: User, client: Client }
  // AccessToken = { access_token, access_token_expires_at, scope, user: User, client: Client }
  // RefreshToken = { refresh_token, refresh_token_expires_at, scope, user: User, client: Client }
  // Token = { ...AccessToken, ...RefreshToken }

  /*** MIDDLEWARES ***/
  // oauth2.token - access_token/refresh_token
  // oauth2.authenticate - check bearer token
  // oauth2.authorize - authorization_code

FAQs

Last updated on 24 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc