
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
jwt-redhat
Advanced tools
This library is not suitable for enterprise use. Repository will be made private. Thank you for understanding.
npm install jwt-redhat
// Typescript
import Jwt from 'jwt'
import { IKeycloakOptions } from 'jwt/src/models'
declare global {
interface Window {
sessionjs: any;
}
}
window.sessionjs = Jwt; // this is optional if you want to invoke the same instance elsewhere
const keycloakOptions: Partial<IKeycloakOptions> = {
clientId: 'unifiedui'
}
Jwt.init(keycloakOptions); // validate session and start the refresh timer
// once the session has initialized, ask session.js some questions
Jwt.onInit(async function () {
// print user's authentication status, internal status, and their user info
if(!Jwt.isAuthenticated()) {
Jwt.login();
}
});
// When this event is triggered we know we have a guaranteed non-expired JWT token
Jwt.onInitialUpdateToken(async function () {
const loggedInUser = Jwt.getUserInfo();
// Any other application specific code can go here.
})
// Javascript
const Jwt = require('jwt');
window.sessionjs = Jwt; // this is optional if you want to invoke the same instance elsewhere
const keycloakOptions = {
clientId: 'unifiedui'
}
// the responseMode defaults to fragment, which works fine in ascension, but query was required for UnifiedUI
const keycloakInitOptions = {
responseMode: 'query'
}
Jwt.init(keycloakOptions, keycloakInitOptions); // validate session and start the refresh timer
// once the session has initialized, ask session.js some questions
Jwt.onInit(() => {
// print user's authentication status, internal status, and their user info
// if the user isn't authenticated, log them in
if(!Jwt.isAuthenticated()) {
Jwt.login();
}
});
// When this event is triggered we know we have a guaranteed non-expired JWT token
Jwt.onInitialUpdateToken(async function () {
const loggedInUser = Jwt.getUserInfo();
// Any other application specific code can go here.
})
There are two ways for determining SSO Environment:
import Jwt, { SsoEnv } from 'jwt-redhat';
...
Jwt.init({
...
ssoEnv: SsoEnv.PROD
})
Create a new servicenow ticket and provide them the information from https://mojo.redhat.com/docs/DOC-1142936
After IAM has created the client profile in their systems, JWT is ready to use.
Note that for testing purposes, you'll probably want to request that your local dev be whitelisted. You'll need to specifically tell IAM that. For example UnifiedUI dev is https://ui.foo.redhat.com which binds to localhost. By default that won't work without some fancy /etc/hosts and/or DNS configuration. So if they whitelist just dev, it will work easy for testing.
Note as well that we highly recommend you use the accessproxy: https://github.com/redhataccess/accessproxy and add the following /etc/hosts config:
127.0.0.1 localhost foo.redhat.com fte.foo.redhat.com ci.foo.redhat.com qa.foo.redhat.com stage.foo.redhat.com prod.foo.redhat.com ui.foo.redhat.com uds.foo.redhat.com qa.foo.access.redhat.com stage.foo.access.redhat.com prod.foo.access.redhat.com
By default we resolve each .foo.redhat.com to the respective JWT login url. For example qa.foo.redhat.com resolves to https://sso.qa.redhat.com/auth.
It may be the case that we'll need to update this project to accomodate your specific url. I would communicate the following to IAM when opening the ticket. Communicate the exact url you will be logging in with, and ask if it can be whitelisted. If they say they will only for dev1/dev2, then we'll need to update this project to include your env specific dev url for dev1 or dev2. We may be able to parameterize that in the future if needed.
Open the javascript console and run localStorage.session_log = true
FAQs
Client side JavaScript library to interact with Red Hat JWT
The npm package jwt-redhat receives a total of 32 weekly downloads. As such, jwt-redhat popularity was classified as not popular.
We found that jwt-redhat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers 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
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.