Skip to content

Add MFA status indicators to login sessions #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/common/api/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface TokenResponse {
type: string;
user: string;
cachefor: number;
mfaAuthenticated: boolean | null;
}

interface AuthParams {
Expand Down Expand Up @@ -158,6 +159,7 @@ interface AuthResults {
device: string;
ip: string;
name?: string;
mfaAuthenticated: boolean | null;
}[];
user: string;
revokeallurl: string;
Expand Down
36 changes: 36 additions & 0 deletions src/features/account/LogInSessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ import { Loader } from '../../common/components';
import { useAppSelector } from '../../common/hooks';
import { useLogout } from '../login/LogIn';

const MfaStatusIndicator: FC<{ mfaAuthenticated: boolean | null }> = ({
mfaAuthenticated,
}) => {
if (mfaAuthenticated === true) {
return (
<Tooltip title="MFA used">
<FontAwesomeIcon icon={faCheck} style={{ color: 'green' }} />
</Tooltip>
);
} else if (mfaAuthenticated === false) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use else if the previous statement was a return

return (
<Tooltip title="Single factor">
<FontAwesomeIcon icon={faCheck} style={{ color: 'red' }} />
</Tooltip>
);
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

return (
<Tooltip title="MFA not supported">
<FontAwesomeIcon icon={faCheck} style={{ color: 'grey' }} />
</Tooltip>
);
}
};

/**
* Content for the Log In Sessions tab in the Account page
*/
Expand Down Expand Up @@ -68,6 +92,7 @@ export const LogInSessions: FC = () => {
<TableCell>Browser</TableCell>
<TableCell>Operating System</TableCell>
<TableCell>IP Address</TableCell>
<TableCell>MFA Status</TableCell>
<TableCell>Action</TableCell>
</TableRow>
</TableHead>
Expand All @@ -86,6 +111,11 @@ export const LogInSessions: FC = () => {
{currentToken?.os} {currentToken?.osver}
</TableCell>
<TableCell>{currentToken?.ip}</TableCell>
<TableCell>
<MfaStatusIndicator
mfaAuthenticated={currentToken?.mfaAuthenticated ?? null}
/>
</TableCell>
<TableCell>
<LogOutButton tokenId={currentToken?.id} />
</TableCell>
Expand All @@ -105,6 +135,7 @@ export const LogInSessions: FC = () => {
<TableCell>Browser</TableCell>
<TableCell>Operating System</TableCell>
<TableCell>IP Address</TableCell>
<TableCell>MFA Status</TableCell>
<TableCell>Action</TableCell>
</TableRow>
</TableHead>
Expand All @@ -124,6 +155,11 @@ export const LogInSessions: FC = () => {
{otherToken.os} {otherToken.osver}
</TableCell>
<TableCell>{otherToken.ip}</TableCell>
<TableCell>
<MfaStatusIndicator
mfaAuthenticated={otherToken.mfaAuthenticated ?? null}
/>
</TableCell>
<TableCell>
<LogOutButton tokenId={otherToken.id} />
</TableCell>
Expand Down
1 change: 1 addition & 0 deletions src/features/auth/authSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface TokenInfo {
type: string;
user: string;
cachefor: number;
mfaAuthenticated: boolean | null;
}

interface AuthState {
Expand Down
Loading