1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

F #6499: remove 2fa created by sunstone and add data-cy (#3069)

This commit is contained in:
Jorge Miguel Lobo Escalona 2024-05-21 18:36:14 +02:00 committed by GitHub
parent eda3084beb
commit fa776d5fb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 15 deletions

View File

@ -308,7 +308,7 @@ module.exports = {
EnterVerificationCode: 'Enter Verification Code',
TwoFactorAuthentication: 'Two Factor Authentication',
RegisterAuthenticationApp: 'Register authentication App',
AuthenticatorAppSunstone: 'Authenticator app (HOTP) [Sunstone]',
AuthenticatorAppSunstone: 'Authenticator app (HOTP) [Legacy]',
AuthenticatorApp: 'Authenticator app (HOTP)',
KeepLoggedIn: 'Keep me logged in',
KeepLast: 'Keep Last',

View File

@ -121,6 +121,7 @@ const Qr = ({
className={classes.qr}
src={data}
alt={Tr(T.ScanThisQr)}
data-cy="qrTfa"
/>
)}
</Grid>
@ -237,7 +238,18 @@ const Tfa = () => {
fireedge?.TWO_FACTOR_AUTH_SECRET) && (
<List className={classes.enabled}>
{sunstone?.TWO_FACTOR_AUTH_SECRET && (
<ListItem>
<ListItem
secondaryAction={
<Button
variant="contained"
size="small"
onClick={handleRemoveTfa}
data-cy="removeTfa"
>
<Trash className="icon" />
</Button>
}
>
<Translate word={T.AuthenticatorAppSunstone} />
</ListItem>
)}
@ -248,7 +260,7 @@ const Tfa = () => {
variant="contained"
size="small"
onClick={handleRemoveTfa}
data-cy="addTfa"
data-cy="removeTfa"
>
<Trash className="icon" />
</Button>

View File

@ -243,18 +243,28 @@ const del = (
const oneConnect = oneConnection(user, password)
getUserInfoAuthenticated(oneConnect, next, (data) => {
const fireedge = data?.USER?.TEMPLATE?.FIREEDGE
if (fireedge) {
const template = data?.USER?.TEMPLATE
const fireedge = template?.FIREEDGE
const sunstone = template?.SUNSTONE
if (fireedge || sunstone) {
let newTemplate = generateNewResourceTemplate(
sunstone || {},
{},
[default2FAOpennebulaTmpVar, default2FAOpennebulaVar],
'SUNSTONE=[%1$s]'
)
if (fireedge) {
newTemplate = generateNewResourceTemplate(fireedge || {}, {}, [
default2FAOpennebulaTmpVar,
default2FAOpennebulaVar,
])
}
oneConnect({
action: Actions.USER_UPDATE,
parameters: [
parseInt(data.USER.ID, 10),
generateNewResourceTemplate(fireedge || {}, {}, [
default2FAOpennebulaTmpVar,
default2FAOpennebulaVar,
]),
1,
],
parameters: [parseInt(data.USER.ID, 10), newTemplate, 1],
callback: (err, value) => {
responseOpennebula(
() => undefined,

View File

@ -257,8 +257,8 @@ const validate2faAuthentication = (informationUser) => {
updaterResponse(httpResponse(accepted, { id: informationUser?.ID }))
} else {
const secret =
template.FIREEDGE[default2FAOpennebulaVar] ||
template.SUNSTONE[default2FAOpennebulaVar]
template.FIREEDGE?.[default2FAOpennebulaVar] ||
template.SUNSTONE?.[default2FAOpennebulaVar]
if (!check2Fa(secret, tfatoken)) {
updaterResponse(httpResponse(unauthorized, '', 'invalid 2fa token'))
} else {