-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from nevissecurity/feature/NEVISACCESSAPP-6059-…
…introduce-authenticator-allowlist NEVISACCESSAPP-6059: introduce authenticator allowlist
- Loading branch information
Showing
14 changed files
with
334 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/userInteraction/AuthenticationAuthenticatorSelectorImpl.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Copyright © 2023 Nevis Security AG. All rights reserved. | ||
*/ | ||
|
||
import { | ||
Authenticator, | ||
AuthenticatorSelectionContext, | ||
AuthenticatorSelectionHandler, | ||
AuthenticatorSelector, | ||
} from '@nevis-security/nevis-mobile-authentication-sdk-react'; | ||
|
||
import { ConfigurationLoader } from '../configuration/ConfigurationLoader'; | ||
import { AuthenticatorItem } from '../model/AuthenticatorItem'; | ||
import * as RootNavigation from '../utility/RootNavigation'; | ||
import { AuthenticatorValidator } from '../utility/validation/AuthenticatorValidator'; | ||
|
||
export enum AuthenticatorSelectorOperation { | ||
registration, | ||
authentication, | ||
} | ||
|
||
export class AuthenticatorSelectorImpl extends AuthenticatorSelector { | ||
operation: AuthenticatorSelectorOperation; | ||
constructor(operation: AuthenticatorSelectorOperation) { | ||
super(); | ||
this.operation = operation; | ||
} | ||
|
||
async selectAuthenticator( | ||
context: AuthenticatorSelectionContext, | ||
handler: AuthenticatorSelectionHandler | ||
): Promise<void> { | ||
console.log('Please select one of the received available authenticators!'); | ||
const configuration = ConfigurationLoader.getInstance().appConfiguration; | ||
const username = context.account.username; | ||
let authenticators: Array<Authenticator> = []; | ||
switch (this.operation) { | ||
case AuthenticatorSelectorOperation.registration: | ||
authenticators = await AuthenticatorValidator.validateForRegistration( | ||
context, | ||
configuration.authenticatorAllowlist | ||
); | ||
break; | ||
case AuthenticatorSelectorOperation.authentication: | ||
authenticators = AuthenticatorValidator.validateForAuthentication( | ||
context, | ||
configuration.authenticatorAllowlist | ||
); | ||
break; | ||
} | ||
|
||
if (authenticators.length === 0) { | ||
console.log('No available authenticators found. Cancelling authenticator selection.'); | ||
return handler.cancel(); | ||
} | ||
|
||
const items: AuthenticatorItem[] = []; | ||
for (const authenticator of authenticators) { | ||
items.push( | ||
new AuthenticatorItem( | ||
authenticator, | ||
await context.isPolicyCompliant(authenticator.aaid), | ||
authenticator.userEnrollment.isEnrolled(username) | ||
) | ||
); | ||
} | ||
|
||
RootNavigation.navigate('SelectAuthenticator', { items: items, handler: handler }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.