GithubHelp home page GithubHelp logo

jastec / oauth2_client_node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from af83/oauth2_client_node

1.0 1.0 0.0 226 KB

A node library providing the bases to implement an OAuth2 client (as connect middleware)

License: BSD 2-Clause "Simplified" License

oauth2_client_node's Introduction

OAuth2 Client in Node

Description

oauth2_client_node is a node library providing the bases to implement an OAuth2 client. It features a connect middleware to ease the integration with any other components.

It implements the OAuth2 web server schema as specified by the draft 10 of the OAuth2 specification.

This project will follow the specification evolutions, so a branch for the draft 11 will soon be created.

Similar projects

oauth2_client_node is developed together with:

  • oauth2_server_node, a connect middleware featuring an OAuth2 server bases.
  • auth_server, an authentication and authorization server in node (using both oauth2_client_node and oauth2_server_node).

Usage

There are two examples of usage in the examples directory, one using Facebook as OAuth2 server, and one using auth_server as OAuth2 server.

To create an OAuth2 client, you will need to to create an oauth2_client_node middleware using oauth2_client.connector. This method returns a connect middleware and takes as arguments:

  • config: hash containing:

    • client, hash containing:

      • base_url: The base URL of the OAuth2 client. Ex: http://domain.com:8080
      • process_login_url: the URL where to the OAuth2 server must redirect the user when authenticated.
      • login_url: the URL where the user must go to be redirected to OAuth2 server for authentication.
      • logout_url: the URL where the user must go so that his session is cleared, and he is unlogged from client.
      • default_redirection_url: default URL to redirect to after login / logout. Optional, default to '/'.
      • crypt_key: string, encryption key used to crypt information contained in states. This is a symmetric key and must be kept secret.
      • sign_key: string, signature key used to sign (HMAC) issued states. This is a symmetric key and must be kept secret.
    • default_server: which server to use for default login when user access login_url (ex: 'facebook.com').

    • servers: hash associating OAuth2 server ids (ex: "facebook.com") with a hash containing (for each):

    • options: optional, hash associating OAuth2 server ids (ex: "facebook.com") with hash containing some options specific to the server. Not all servers have to be listed here, neither all options. Possible options:

      • valid_grant: a function which will replace the default one to check the grant is ok. You might want to use this shortcut if you have a faster way of checking than requesting the OAuth2 server with an HTTP request.
      • treat_access_token: a function which will replace the default one to do something with the access token. You will tipically use that function to set some info in session.
      • transform_token_response: a function which will replace the default one to obtain a hash containing the access_token from the OAuth2 server reply. This method should be provided if the OAuth2 server we are requesting does not return JSON encoded data.

Once set and plug, the oauth2_client middleware will catch and answer requests aimed at the oauth2 client (login, logout and process_login endpoints).

Dependencies

  • connect
  • request
  • serializer

Tested with node v0.4.

Tests

with nodetk.

Projects using oauth2_client_node

A wiki page lists the projects using oauth2_client_node. Don't hesitate to edit it.

License

BSD.

oauth2_client_node's People

Contributors

francois2metz avatar virtuo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.