Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
oauth20-provider
Advanced tools
OAuth 2.0 provider toolkit for nodeJS with connect/express support. Supports all the four authorization flows: authorization code, implicit, client credentials, password.
One more oAuth 2.0 service provider? Yes!
$ npm install oauth20-provider
Look into ."/test/server/ directory" for working example with in-memory and redis storage models.
By default module sets abstract models which should be redefined, library does not force any implementation.
Refresh tokens are credentials used to obtain access tokens. Refresh tokens are issued to the client by the authorization server and are used to obtain a new access token when the current access token becomes invalid or expires, or to obtain additional access tokens with identical or narrower scope (access tokens may have a shorter lifetime and fewer permissions than authorized by the resource owner). Read more
Redefinable functions Look at "./lib/model/refreshToken.js" for further information.
Access tokens are credentials used to access protected resources. An access token is a string representing an authorization issued to the client. The string is usually opaque to the client. Tokens represent specific scopes and durations of access, granted by the resource owner, and enforced by the resource server and authorization server. Read more
Redefinable functions Look at "./lib/model/accessToken.js" for further information.
Before initiating the protocol, the client registers with the authorization server. The means through which the client registers with the authorization server are beyond the scope of this specification but typically involve end-user interaction with an HTML registration form. Read more
Redefinable functions Look at "./lib/model/client.js" for further information.
The authorization code is obtained by using an authorization server as an intermediary between the client and resource owner. User only by authorization code flow, no need to initialize it if one dont use this grant. Read more
Redefinable functions Look at "./lib/model/code.js" for further information.
User is a registered person in the service. Model should contain unique identifier, password and sometimes additional unique key (for example username/email). There is no common scheme for this type of object, feel free to implement it your way.
Redefinable functions Look at "./lib/model/user.js" for further information.
Page is used to ask user whether user agree or not to allow client to access his information with current scope. Controller should return POST form with decision parameter (0 - user does not allow, 1 - user allows).
Redefinable Look at "./contoller/authorization/decision.js" for further information.
First of all include and initialize oauth20-provider library:
oauth2lib = require('./oauth20-provider.js');
oauth2 = new oauth2lib({log: {level: 2}});
Library is compatible with express/connect servers, inject oauth2 into your server.
server.use(oauth2.inject());
Token endpoint
server.post('/token', oauth2.controller.token);
Authorization endpoint
server.get('/authorization', isAuthorized, oauth2.controller.authorization, function(req, res) {
// Render our decision page
// Look into ./test/server for further information
res.render('authorization', {layout: false});
});
server.post('/authorization', isAuthorized, oauth2.controller.authorization);
Middleware isAuthrorized is used to check user login. If user is not logged in - show authorization form instead. Simple implementation:
function isUserAuthorized(req, res, next) {
if (req.session.authorized) next();
else {
var params = req.query;
params.backUrl = req.path;
res.redirect('/login?' + query.stringify(params));
}
};
Your authorizaton server is ready for work.
Copyright (c) 2013 Tim Shamilov
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
OAuth 2.0 provider toolkit for nodeJS
The npm package oauth20-provider receives a total of 125 weekly downloads. As such, oauth20-provider popularity was classified as not popular.
We found that oauth20-provider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.