solid-node-interactive-auth
v1.1.1
Published
Easily authenticate Node.js apps with Solid identity servers by opening the user's Web browser
Downloads
418
Maintainers
Readme
Interactive Solid authentication in Node.js
Easily authenticate Node.js apps with Solid identity servers by opening the user's Web browser.
Internally, this tool will setup a temporary Web server on the localhost to allow authentication data to be handled easily and safely.
This is to be used as a tool next to @inrupt/solid-client-authn-node
.
Try out how it works
To see how the interactive authentication works for the end-user, you can run this command:
$ npx solid-node-interactive-auth https://solidcommunity.net/
Logged in as https://<MY USERNAME>.solidcommunity.net/profile/card#me
You can replace https://solidcommunity.net/ with the identity provider you want to authenticate with.
Installation
$ npm install solid-node-interactive-auth
or
$ yarn add solid-node-interactive-auth
This tool requires @inrupt/solid-client-authn-node
as a peer dependency:
$ npm install @inrupt/solid-client-authn-node
or
$ yarn add @inrupt/solid-client-authn-node
Usage
The following code will trigger the user's Web browser to be opened to trigger the login sequence:
import { Session } from '@inrupt/solid-client-authn-node';
import { interactiveLogin } from 'solid-node-interactive-auth';
(async function() {
// Create a new session and log in by opening the Web browser
const session = new Session();
await interactiveLogin({
session,
oidcIssuer: 'https://solidcommunity.net/',
});
// Perform operations with this session
// such as session.fetch()
// Log out once you're done (avoids hanging Node.js process)
await session.logout();
})();
If you don't have any specific needs for the Session
object,
you can also just let this tool create one for you:
const session = await interactiveLogin({
oidcIssuer: 'https://solidcommunity.net/',
});
License
This software is written by Ruben Taelman.
This code is released under the MIT license.