dadi / passport Goto Github PK
View Code? Open in Web Editor NEWA library for generating access tokens to authenticate with DADI platform components
A library for generating access tokens to authenticate with DADI platform components
This might be useful for people that do not wish to store their tokens on a flat file in local storage. For example, a service that runs on multiple servers might wish to use the same bearer token across all instances, so they could all use a shared token wallet.
I imagine this being a massive overkill for the majority of use cases (after all, a round-trip to a remote database might be as expensive as requesting a new bearer token every time), but I wanted to discuss the idea and explore different token storage solutions, to see if people have a need for them.
When the wallet directory doesn't exist, the app crashes with a ENOENT
error:
{ [Error: ENOENT: no such file or directory, open '/Users/eduardoboucas/Sites/api-wrapper/.wallet/token.http-localhost3014.worker.json']
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/eduardoboucas/Sites/api-wrapper/.wallet/token.http-localhost3014.worker.json' }
We need to ensure the directory is created at runtime.
We have at least two error cases to handle, to match the existing auth token request in Web:
Currently in Web these are handled as follows:
var err = new Error('Authentication');
err.message = 'No token received, invalid credentials.';
err.remoteIp = options.hostname;
err.remotePort = options.port;
err.path = options.path;
var err = new Error('Authentication');
err.message = "Couldn't request accessToken";
err.remoteIp = options.hostname;
err.remotePort = options.port;
err.path = options.path;
Currently in Passport I get an unhandled exception response if the credentials are incorrect. In some of the other apps we've started to use the JSON API spec for errors. Could we look at returning an errors collection in passport also?
For example:
{
"errors": [
{
"status": "Not Found",
"code": "",
"title": "URL Not Found",
"details": "The request for URL '<url>' returned a 404."
}
]
}
The API returns tokens in the following format. Can the passport response be the same?
{
"accessToken": "243606ed-e43f-41c6-8e53-75e5e2f85b82"
"tokenType": "Bearer"
"expiresIn": 1800
}
The http2 module used in Passport (Node.js) is reported as deprecated when installing DADI Web 4.x.
npm WARN deprecated [email protected]: Use the built-in module in node 9.0.0 or newer, instead
We're not using HTTP2 just yet - I wonder if this is something we need to address in Passport?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.