@opengeoweb/authentication 9.17.0 → 9.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import React, { useRef } from 'react';
2
2
  import axios from 'axios';
3
3
  import { Navigate, useLocation, Link } from 'react-router-dom';
4
4
  import { useIsMounted, AlertBanner } from '@opengeoweb/shared';
5
- import { KEEP_ALIVE_POLLER_IN_SECONDS, MILLISECOND_TO_SECOND, getCurrentTimeInSeconds, refreshAccessTokenAndSetAuthContext, makeCredentialsFromTokenResponse } from '@opengeoweb/api';
5
+ import { KEEP_ALIVE_POLLER_IN_SECONDS, MILLISECOND_TO_SECOND, getCurrentTimeInSeconds, refreshAccessTokenAndSetAuthContext, makeCredentialsFromTokenResponse, GEOWEB_ROLE_USER } from '@opengeoweb/api';
6
6
  import { ThemeWrapper } from '@opengeoweb/theme';
7
7
  import { useTranslation, Trans } from 'react-i18next';
8
8
  import 'i18next';
@@ -355,10 +355,10 @@ var SHARED = '__core-js_shared__';
355
355
  var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$2(SHARED, {});
356
356
 
357
357
  (store$3.versions || (store$3.versions = [])).push({
358
- version: '3.36.1',
358
+ version: '3.37.1',
359
359
  mode: 'global',
360
360
  copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
361
- license: 'https://github.com/zloirock/core-js/blob/v3.36.1/LICENSE',
361
+ license: 'https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE',
362
362
  source: 'https://github.com/zloirock/core-js'
363
363
  });
364
364
 
@@ -5570,7 +5570,9 @@ const authConfigKeys = {
5570
5570
  GW_AUTH_TOKEN_URL: null,
5571
5571
  GW_APP_URL: null,
5572
5572
  GW_BE_VERSION_BASE_URL: null,
5573
- GW_AUTH_CLIENT_ID: null
5573
+ GW_AUTH_CLIENT_ID: null,
5574
+ GW_AUTH_ROLE_CLAIM_NAME: null,
5575
+ GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN: null
5574
5576
  };
5575
5577
  const getRandomString = () => {
5576
5578
  const array = new Uint32Array(8);
@@ -5594,7 +5596,9 @@ const getAuthConfig = _configUrls => {
5594
5596
  GW_AUTH_TOKEN_URL,
5595
5597
  GW_APP_URL,
5596
5598
  GW_BE_VERSION_BASE_URL,
5597
- GW_AUTH_CLIENT_ID
5599
+ GW_AUTH_CLIENT_ID,
5600
+ GW_AUTH_ROLE_CLAIM_NAME,
5601
+ GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN
5598
5602
  } = _configUrls;
5599
5603
  const sessionStorageProvider = getSessionStorageProvider();
5600
5604
  const loginUrl = replaceTemplateKeys(GW_AUTH_LOGIN_URL, GW_AUTH_CLIENT_ID, GW_APP_URL, sessionStorageProvider.getOauthState(), sessionStorageProvider.getOauthCodeChallenge());
@@ -5605,7 +5609,9 @@ const getAuthConfig = _configUrls => {
5605
5609
  GW_AUTH_TOKEN_URL,
5606
5610
  GW_APP_URL,
5607
5611
  GW_BE_VERSION_BASE_URL,
5608
- GW_AUTH_CLIENT_ID
5612
+ GW_AUTH_CLIENT_ID,
5613
+ GW_AUTH_ROLE_CLAIM_NAME,
5614
+ GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN
5609
5615
  };
5610
5616
  };
5611
5617
  const AuthenticationContext = /*#__PURE__*/React.createContext({
@@ -5621,6 +5627,7 @@ const useAuthenticationDefaultProps = () => {
5621
5627
  const [hasConnectionIssue, setHasConnectionIssue] = React.useState(false);
5622
5628
  const emptyCredentials = {
5623
5629
  username: '',
5630
+ roles: [],
5624
5631
  token: '',
5625
5632
  refresh_token: '',
5626
5633
  expires_at: 0,
@@ -5762,7 +5769,7 @@ const HandleOAuth2Code = () => {
5762
5769
  };
5763
5770
  try {
5764
5771
  const res = yield axiosInstance.post(authConfig.GW_AUTH_TOKEN_URL, data, config);
5765
- const newAuth = makeCredentialsFromTokenResponse(res);
5772
+ const newAuth = makeCredentialsFromTokenResponse(res, authConfig);
5766
5773
  if (isMounted.current) {
5767
5774
  onSetAuth(newAuth);
5768
5775
  onLogin(true);
@@ -5939,7 +5946,7 @@ const UserMenuRoles = ({
5939
5946
  color: 'geowebColors.typographyAndIcons.text',
5940
5947
  opacity: 1
5941
5948
  }
5942
- }, t('auth-role-title')), roles.map(role => ( /*#__PURE__*/React.createElement(FormControlLabel, {
5949
+ }, t('auth-role-title')), roles && roles.map(role => ( /*#__PURE__*/React.createElement(FormControlLabel, {
5943
5950
  control: /*#__PURE__*/React.createElement(Radio, {
5944
5951
  disabled: isLoading,
5945
5952
  checked: _currentRole === role.name
@@ -6699,18 +6706,12 @@ $({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
6699
6706
  }
6700
6707
  });
6701
6708
 
6702
- const roles = [{
6703
- name: 'preset-admin',
6704
- title: 'Preset-admin'
6705
- }, {
6706
- name: 'user',
6707
- title: 'User'
6708
- }];
6709
6709
  const UserMenuRolesConnect = ({
6710
- temporaryOnChangeRoleForDemo: _temporaryOnChangeRoleForDemo = () => {}
6710
+ temporaryOnChangeRoleForDemo: _temporaryOnChangeRoleForDemo = () => {},
6711
+ roles
6711
6712
  }) => {
6712
6713
  const [isLoading, setIsLoading] = React.useState(false);
6713
- const [currentRole, setCurrentRole] = React.useState(roles[1].name);
6714
+ const [currentRole, setCurrentRole] = React.useState(GEOWEB_ROLE_USER.name);
6714
6715
  const dispatch = useDispatch();
6715
6716
  const {
6716
6717
  t
@@ -6772,4 +6773,4 @@ const RequireAuth = ({
6772
6773
  }));
6773
6774
  };
6774
6775
 
6775
- export { AUTH_NAMESPACE, AuthenticationContext, AuthenticationProvider, HandleOAuth2Code as Code, OAuth2Login as Login, OAuth2Logout as Logout, RequireAuth, SessionStorageKey, UserMenuRoles, UserMenuRolesConnect, authTranslations, getAuthConfig, getCodeChallenge, getCurrentUrlLocation, getRandomString, getSessionStorageProvider, roles, useAuthenticationContext, useAuthenticationDefaultProps };
6776
+ export { AUTH_NAMESPACE, AuthenticationContext, AuthenticationProvider, HandleOAuth2Code as Code, OAuth2Login as Login, OAuth2Logout as Logout, RequireAuth, SessionStorageKey, UserMenuRoles, UserMenuRolesConnect, authTranslations, getAuthConfig, getCodeChallenge, getCurrentUrlLocation, getRandomString, getSessionStorageProvider, useAuthenticationContext, useAuthenticationDefaultProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/authentication",
3
- "version": "9.17.0",
3
+ "version": "9.19.0",
4
4
  "description": "GeoWeb authentication library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -15,7 +15,7 @@
15
15
  "@opengeoweb/theme": "*",
16
16
  "i18next": "^23.7.11",
17
17
  "react-i18next": "^13.5.0",
18
- "@opengeoweb/snackbar": "9.17.0",
18
+ "@opengeoweb/snackbar": "9.19.0",
19
19
  "react-redux": "^8.1.3",
20
20
  "@reduxjs/toolkit": "^1.9.7",
21
21
  "@mui/material": "~5.15.11"
@@ -4,6 +4,8 @@ export interface AuthenticationConfig {
4
4
  GW_AUTH_LOGIN_URL: string;
5
5
  GW_AUTH_LOGOUT_URL: string;
6
6
  GW_AUTH_TOKEN_URL: string;
7
+ GW_AUTH_ROLE_CLAIM_NAME?: string;
8
+ GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN?: string;
7
9
  GW_APP_URL: string;
8
10
  GW_BE_VERSION_BASE_URL?: string;
9
11
  GW_AUTH_CLIENT_ID: string;
@@ -4,7 +4,7 @@ export interface Role {
4
4
  title: string;
5
5
  }
6
6
  export declare const UserMenuRoles: React.FC<{
7
- roles: Role[];
7
+ roles?: Role[];
8
8
  currentRole?: string;
9
9
  onChangeRole: (role: Role) => void;
10
10
  isLoading: boolean;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Role } from './UserMenuRoles';
3
- export declare const roles: Role[];
4
3
  export declare const UserMenuRolesConnect: React.FC<{
5
4
  temporaryOnChangeRoleForDemo?: (role: Role) => void;
5
+ roles?: Role[];
6
6
  }>;