Skip to content

Commit

Permalink
Allow extended apikeys to be created when enabled in the system
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-sgaron committed Mar 25, 2021
1 parent 43fbd9e commit 9ad1adf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/hooks/useMyUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type ConfigurationDefinition = {
auth: {
allow_2fa: boolean;
allow_apikeys: boolean;
allow_extended_apikeys: boolean;
allow_security_tokens: boolean;
};
system: {
Expand Down
3 changes: 3 additions & 0 deletions src/components/routes/user/api_keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
useMediaQuery,
useTheme
} from '@material-ui/core';
import useALContext from 'components/hooks/useALContext';
import useMyAPI from 'components/hooks/useMyAPI';
import useMySnackbar from 'components/hooks/useMySnackbar';
import React, { useState } from 'react';
Expand All @@ -27,6 +28,7 @@ type APIKeysProps = {
export default function APIKeys({ user, toggleAPIKey }: APIKeysProps) {
const { t } = useTranslation(['user']);
const [selectedAPIKey, setSelectedAPIKey] = useState(null);
const { configuration } = useALContext();
const [tempAPIKey, setTempAPIKey] = useState(null);
const [tempKeyName, setTempKeyName] = useState('');
const [tempKeyPriv, setTempKeyPriv] = useState('READ');
Expand Down Expand Up @@ -123,6 +125,7 @@ export default function APIKeys({ user, toggleAPIKey }: APIKeysProps) {
<MenuItem value="READ">{t('apikeys.r_token')}</MenuItem>
<MenuItem value="READ_WRITE">{t('apikeys.rw_token')}</MenuItem>
<MenuItem value="WRITE">{t('apikeys.w_token')}</MenuItem>
{configuration.auth.allow_extended_apikeys && <MenuItem value="EXTENDED">{t('apikeys.e_token')}</MenuItem>}
</Select>
</div>
<div style={{ alignSelf: 'flex-end', paddingLeft: sp1 }}>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"apikeys": "Manage API Keys",
"apikeys.add": "Add",
"apikeys.desc": "Randomly generated password used in scripts to gain limited data access for either reading, writing or both.",
"apikeys.e_token": "Extended",
"apikeys.list": "Configured API Keys",
"apikeys.new_notice_text": "This will be the only time where you'll actually see the key. Make sure you copy/paste that key in the script where you want to use it now because once you close this window you can no longer see the key. If you forget the key you'll have to delete it and re-create another.",
"apikeys.new_notice_title": "* Important *",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/fr/help/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"function": "Fonction interne",
"methods": "Méthodes autorisées",
"path": "Chemin d'API",
"priv.E": "Étendu",
"priv.E": "Étendue",
"priv.R": "Lecture",
"priv.W": "Écriture",
"protected": "Nécessite une authentification",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"apikeys": "Gérer les clés API",
"apikeys.add": "Ajouter",
"apikeys.desc": "Mot de passe généré aléatoirement pour utiliser dans les scripts afin d'obtenir un accès limité aux données pour la lecture, l'écriture ou même les deux.",
"apikeys.e_token": "Étendue",
"apikeys.list": "Clés API configurées",
"apikeys.new_notice_text": "Ce sera le seul moment où vous verrez réellement la clé. Assurez-vous de copier/coller cette clé dans le script où vous souhaitez l'utiliser maintenant, car une fois que vous fermez cette fenêtre, vous ne pouvez plus voir la clé. Si vous oubliez la clé, vous devrez la supprimer et en recréer une autre.",
"apikeys.new_notice_title": "* Important *",
Expand Down

0 comments on commit 9ad1adf

Please sign in to comment.