TopGit theo dõi jaredhanson/oauth2orize trên GitHub trong nhóm Backend, đã đạt 3.5k sao. OAuth 2.0 authorization server toolkit for Node.js.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
OAuth2orize is an authorization server toolkit for Node.js. It provides a suite
of middleware that, combined with Passport
authentication strategies and application-specific route handlers, can be used
to assemble a server that implements the OAuth 2.0
protocol.
Advertisement
Node.js API Masterclass With Express & MongoDB Create a real world backend for a bootcamp directory app
Status:
Install
$ npm install oauth2orize
Usage
OAuth 2.0 defines an authorization framework, allowing an extensible set of
authorization grants to be exchanged for access tokens. Implementations are
free to choose what grant types to support, by using bundled middleware to
support common types or plugins to support extension types.
Create an OAuth Server
Call createServer() to create a new OAuth 2.0 server. This instance exposes
middleware that will be mounted in routes, as well as configuration options.
var server = oauth2orize.createServer();
Register Grants
A client must obtain permission from a user before it is issued an access token.
This permission is known as a grant, the most common type of which is an
authorization code.
server.grant(oauth2orize.grant.code(function(client, redirectURI, user, ares, done) {
var code = utils.uid(16);
var ac = new AuthorizationCode(code, client.id, redirectURI, user.id, ares.scope);
ac.save(function(err) {
if (err) { return done(err); }
return done(null, code);
});
}));
OAuth2orize also bundles support for implicit token grants.
Register Exchanges
After a client has obtained an authorization grant from the user, that grant can
be exchanged for an access token.
server.exchange(oauth2orize.exchange.code(function(client, code, redirectURI, done) {
AuthorizationCode.findOne(code, function(err, code) {
if (err) { return done(err); }
if (client.id !== code.clientId) { return done(null, false); }
if (redirectURI !== code.redirectUri) { return done(null, false); }
var token = utils.uid(256);
var at = new AccessToken(token, code.userId, code.clientId, code.scope);
at.save(function(err) {
if (err) { return done(err); }
return done(null, token);
});
});
}));
OAuth2orize also bundles support for password and client credential grants.
Additionally, bundled refresh token support allows expired access tokens to be
renewed.
Implement Authorization Endpoint
When a client requests authorization, it will redirect the user to an
authorization endpoint. The server must authenticate the user and obtain
their permission.
In this example, connect-ensure-login
middleware is being used to make sure a user is authenticated before
authorization proceeds. At that point, the application renders a dialog
asking the user to grant access. The resulting form submission is processed
using decision middleware.
Based on the grant type requested by the client, the appropriate grant
module registered above will be invoked to issue an authorization code.
Session Serialization
Obtaining the user's authorization involves multiple request/response pairs.
During this time, an OAuth 2.0 transaction will be serialized to the session.
Client serialization functions are registered to customize this process, which
will typically be as simple as serializing the client ID, and finding the client
by ID when deserializing.
Passport strategies are used to authenticate the
client, in this case using either an HTTP Basic authentication header (as
provided by passport-http) or
client credentials in the request body (as provided by
passport-oauth2-client-password).
Based on the grant type issued to the client, the appropriate exchange module
registered above will be invoked to issue an access token. If an error occurs,
errorHandler middleware will format an error response.
Implement API Endpoints
Once an access token has been issued, a client will use it to make API requests
on behalf of the user.
In this example, bearer tokens are issued, which are then authenticated using
an HTTP Bearer authentication header (as provided by passport-http-bearer)
Examples
This example demonstrates
how to implement an OAuth service provider, complete with protected API access.
Related Modules
oauth2orize-openid — Extensions to support OpenID Connect
oauth2orize-jwt-bearer — Exchange JWT assertions for access tokens
passport-http-bearer — Bearer token authentication strategy for APIs
Debugging
oauth2orize uses the debug module. You can enable debugging messages on the console by doing export DEBUG=oauth2orize before running your application.
License
The MIT License
Copyright (c) 2012-2021 Jared Hanson <https://www.jaredhanson.me/>
jaredhanson/oauth2orize thuộc nhóm Backend trên TopGit, cùng 3 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về jaredhanson/oauth2orize ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/jaredhanson/oauth2orize là nguồn chính thức.
jaredhanson/oauth2orize có phải mã nguồn mở không?
Có — jaredhanson/oauth2orize phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/jaredhanson/oauth2orize.
jaredhanson/oauth2orize có trang demo không?
Dự án có trang chủ ở https://www.oauth2orize.org?utm_source=github&utm_medium=referral&utm_campaign=oauth2orize. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
jaredhanson/oauth2orize dùng license gì?
jaredhanson/oauth2orize phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
jaredhanson/oauth2orize là gì?
jaredhanson/oauth2orize (jaredhanson/oauth2orize) là dự án JavaScript trên GitHub. Theo mô tả gốc: OAuth 2.0 authorization server toolkit for Node.js.
Vì sao jaredhanson/oauth2orize được xếp vào nhóm Backend?
TopGit xếp jaredhanson/oauth2orize vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "express", "oauth2", "oauth2orize"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
oauth2orize có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về oauth2orize.