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

oauth2orize-password-realm

v0.1.0

Published

Password exchange with realm support for OAuth2orize.

Downloads

4

Readme

oauth2orize-password-realm

Build Coverage Quality Dependencies

Password exchange with realm support for OAuth2orize.

This exchange is used to exchange a password credential for an access token. This is similar in functionality to the standard Resource Owner Password Credentials Grant defined by OAuth 2.0, but includes the ability to indicate a specific realm.

Realms in this exchange are intended to be used identically to that of HTTP Authentication, where realms allow a server to be partitioned into a set of protection spaces, each with its own authorization database.

Install

$ npm install oauth2orize-password-realm

Usage

Register Exchange

Register the exchange with an OAuth 2.0 server.

var password = require('oauth2orize-password-realm').exchange.password;

server.exchange('http://auth0.com/oauth/grant-type/password-realm', password(function(client, username, password, realm, scope, done) {
  // verify password and issue access token
  var token = 'secret';
  return done(null, token);
});

Exchange Password for Access Token

POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded

grant_type=http%3A%2F%2Fauth0.com%2Foauth%2Fgrant-type%2Fpassword-realm&username=johndoe&password=A3ddj3w&realm=users

Considerations

Realms

Realms are used to allow a server to be partitioned into a set of protection spaces, each with its own authentication scheme and/or authorization database.

One use case for this is when a company maintains separate user directories, for example one directory for employees and another for customers. An application that allows both empolyees and customers to log in can present a user interface with a dropdown containing "Employees" or "Customers" as realms. The realm value, along with the username and password credentials, is then submitted to the token endpoint. The authorization server would use the realm value to determine which directory to use when verifying the password.

Relation to Resource Owner and Client Credentials

The functionality of this exchange overlaps to some degree with both the Resource Owner Password Credentials Grant and the Client Credentials Grant defined by OAuth 2.0, in that both allow a password credential to be exchanged for an access token. The former allows a resource owner (typically a user) to obtain an access token, while the latter allows a client to exchange its client secret for an access token.

This exchange offers a more general form of password exchange, and could be used as an alternative, unified implementation where the two types of entities are divided into unique realms (for example, users and clients).

For compatibility, it is recommended to continue to support both password and client_credentials exchanges. If additional entities, such as resource servers, need to be able to obtain access tokens, implementing this exchange offers more flexibility.

Contributing

Tests

The test suite is located in the test/ directory. All new features are expected to have corresponding test cases. Ensure that the complete test suite passes by executing:

$ make test

Coverage

The test suite covers 100% of the code base. All new feature development is expected to maintain that level. Coverage reports can be viewed by executing:

$ make test-cov
$ make view-cov

Sponsors

This project is sponsored by Auth0.

License

The MIT License

Copyright (c) 2016 Jared Hanson <http://jaredhanson.net/>