From 6b964809ed2b67a6f32579455e40219357594e90 Mon Sep 17 00:00:00 2001 From: Adam Morrison Date: Sun, 1 Oct 2023 16:51:44 +0100 Subject: [PATCH] f-consumer-oidc@1.4.2 Add option to provide OIDC cookie name --- packages/services/f-consumer-oidc/CHANGELOG.md | 7 +++++++ packages/services/f-consumer-oidc/README.md | 3 ++- packages/services/f-consumer-oidc/package.json | 2 +- .../services/f-consumer-oidc/src/user-manager-factory.js | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/services/f-consumer-oidc/CHANGELOG.md b/packages/services/f-consumer-oidc/CHANGELOG.md index b2bd123b24..fc6059477a 100644 --- a/packages/services/f-consumer-oidc/CHANGELOG.md +++ b/packages/services/f-consumer-oidc/CHANGELOG.md @@ -3,6 +3,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +v1.4.2 +------------------------------ +* October 1, 2023* + +### Added +- Ability to provide your own OIDC cookie name + v1.4.1 ------------------------------ diff --git a/packages/services/f-consumer-oidc/README.md b/packages/services/f-consumer-oidc/README.md index 6b5852506e..814121c0fe 100644 --- a/packages/services/f-consumer-oidc/README.md +++ b/packages/services/f-consumer-oidc/README.md @@ -72,7 +72,7 @@ The exports are: This function attempts to get a valid JWT for the current user. It works as follows: -* it stores the token in a cookie (`je-oidc`), so if the user has already done this in their session it will retrieve that +* it stores the token in a cookie (`oidcSettings.cookie_name`), so if the user has already done this in their session it will retrieve that * for the page lifetime (i.e. JS variable) it remembers if the user is not logged in, so that it doesn't attempt to get a token repeatedly * by default it will silently refresh the token close to its expiry time, if possible. This functionality is built in to [`oidc-client`](https://github.com/IdentityModel/oidc-client-js/wiki). * you should set the `silentRequestTimeout` setting to a low value, to avoid blocking UI components. By default this is a a very high value - 100 seconds. @@ -83,6 +83,7 @@ Usage: import { silentSignIn } from `@justeat/f-consumer-oidc`; const oidcSettings = { + cookie_name: 'my-cookie-name', silentRequestTimeout: 2000 }; diff --git a/packages/services/f-consumer-oidc/package.json b/packages/services/f-consumer-oidc/package.json index bacc68256d..831bc6bff7 100644 --- a/packages/services/f-consumer-oidc/package.json +++ b/packages/services/f-consumer-oidc/package.json @@ -1,6 +1,6 @@ { "name": "@justeat/f-consumer-oidc", - "version": "1.4.1", + "version": "1.4.2", "description": "Authentication helper to communicate with open apis", "main": "dist/f-consumer-oidc.umd.js", "module": "dist/f-consumer-oidc.es.js", diff --git a/packages/services/f-consumer-oidc/src/user-manager-factory.js b/packages/services/f-consumer-oidc/src/user-manager-factory.js index c3ff96fa61..2649c982b3 100644 --- a/packages/services/f-consumer-oidc/src/user-manager-factory.js +++ b/packages/services/f-consumer-oidc/src/user-manager-factory.js @@ -6,11 +6,11 @@ export function userManagerFactory ({ UserManager }, settings) { const root = `${location.protocol}//${location.host}`; function getCookieData () { - return Cookies.getJSON('je-oidc') || {}; + return Cookies.getJSON(settings.cookie_name) || {}; } function setCookieData (obj) { - Cookies.set('je-oidc', obj); // TODO: expiry + Cookies.set(settings.cookie_name, obj); // TODO: expiry } const userStore = { @@ -45,6 +45,7 @@ export function userManagerFactory ({ UserManager }, settings) { const defaultSettings = { authority: root, client_id: 'je_web_native', + cookie_name: 'je-oidc', // Default cookie name response_type: 'code', scope: 'openid mobile_scope offline_access', silent_redirect_uri: `${root}/tokenweb/content/silent-callback.html`,