![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Integrating with the other apps your customers use is one of the most common use cases for modern web apps. Most of the time, that happens via OAuth. Legolas builds on existing tools to provide a secure, easy, and user friendly way to do that.
While Passport does a great job of giving you the tools to build your authentication system on top of an OAuth provider, you still need to do the work yourself to build out a consistent, user friendly way of handling integrations securely. Legolas aims to make this as simple as entering a few parameters into a configuration variable for any provider that implements the OAuth 1.0 (deprecated, I know, but it's still being used) or 2.0 specifications.
While Passport gives hundreds of integrations, they're designed to be authentication strategies rather than integration strategies. Legloas is focused on integration, and builds on Passport.
Legolas makes it super simple to add integrations, give updates to your client via a web socket with Engine.io when OAuth completes without interrupting flow, and define what should happen when OAuth completes. For a video demo, click below:
After authenticating, you'll have a new key of oauth.PROVIDER_NAME
in your existing session.
/oauth/2.0/mailchimp
{
"1.0": {
"aweber": [
"https://auth.aweber.com/1.0/oauth/request_token",
"https://auth.aweber.com/1.0/oauth/access_token",
"https://auth.aweber.com/1.0/oauth/authorize",
"CONSUMER_KEY",
"CONSUMER_SECRET"
]
},
"2.0": {
"mailchimp": [
"https://login.mailchimp.com/oauth2/authorize",
"https://login.mailchimp.com/oauth2/token",
"CLIENT_ID",
"CLIENT_SECRET"
]
}
}
Notice that this follows the pattern of REQUEST_TOKEN_URL
, ACCESS_TOKEN_URL
, AUTHORIZE_URL
, CONSUMER_KEY
, CONSUMER_SECRET
for OAuth 1.0, and AUTHORIZE_URL
, TOKEN_URL
, CLIENT_ID
, CLIENT_SECRET
for OAuth 2.0.
Additionally, extra param can be passed to both implementations as an object, which will then apply custom params:
{
"scope": "ManageLists,ImportSubscribers",
"type": "web_server"
}
The following is a complete example app which will show youhow to coordinate the entire process:
/*
* You'll want these dependencies to run the example code:
*
* "express": "^4.12.4",
* "express-session": "^1.11.2",
* "jade": "^1.10.0"
*/
var express = require('express');
var app = express();
var session = require('express-session');
var path = require('path');
var port = 3000;
/*
* Passport requires we use sessions
*/
app.use(session(
{
secret: 'foo',
resave: false,
saveUninitialized: true,
cookie: {}
}
));
/*
* Set views and pub folder
*/
app.set('views', __dirname);
app.set('view engine', 'jade');
app.use('/', express.static(path.join(__dirname, 'example-client')));
/*
* Here's a view to see our integrations
*/
app.get('/', function(req, res){
res.render('example', {integrations: integrations});
});
/*
* Listen on the server
*/
var server = app.listen(port, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
/*
* Add the integrations from an environment variable.
*/
var integrations = JSON.parse(process.env.integrations);
var OAuthIntegrations = require('legolas');
integrations.oncomplete = {
mailchimp: function(data, session, socket){
console.log('mailchimp oncomplete fired', data);
}
}
new OAuthIntegrations(app, 'http://127.0.0.1:'+port, integrations, server);
Note: You can grab the engine.io-client.js from their repo.
html
head
title OAuth Examples
body
h1 Click an Integration to Run It
- for (var key in integrations) {
h2 OAuth
span= key
- for (var k_ in integrations[key]){
p
a(href="/oauth/#{key}/#{k_}", target="_blank")= k_
- }
- }
script(src="//code.jquery.com/jquery-2.1.4.min.js")
script(src="/engine.io-client.js")
script(src="/client.js")
$(document).ready(function(){
/*
* Initialize Socket Server
*/
var socket = new eio.Socket('ws://127.0.0.1:3000/');
socket.on('open', function(){
$.get('/socket/register/'+socket.id);
socket.on('message', function(data){
console.log('message received', data);
var msg = JSON.parse(data);
if(msg.oauth){
for(var key in msg.oauth){
if(msg.oauth[key].complete){
var el = oauthInProgress[key];
el.innerHTML = el.innerHTML.replace('in progress', 'complete');
}
}
}
});
});
/*
* Keep track of what's in progress
*/
var oauthInProgress = {};
/*
* Add Link Handlers
*/
var links = $('a');
links.each(function(i, link){
link.onclick = function(){
oauthInProgress[this.innerHTML] = this;
this.innerHTML += ' - in progress';
console.log('in progress is', oauthInProgress);
}
});
});
Run like this (notice I'm setting the contents of a file to an environment variable to keep keys out of code):
integrations=$(cat integrations.json) node example.js
FAQs
Unknown package
The npm package legolas receives a total of 3 weekly downloads. As such, legolas popularity was classified as not popular.
We found that legolas 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.