Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Authenticate users using authenticator apps
ResourceFunction["AuthenticatorAppVerify"]["New",{issuer,user}] generates a secret value for storage in an authenticator app. | |
ResourceFunction["AuthenticatorAppVerify"][code,secret] tests an authenticator app generated code against the stored secret. |
Create secret information to share with user "jonm" of our website "mywebsite":
| In[1]:= |
| Out[1]= | ![]() |
You can display the barcode and/or the URI to help the user to enter the secret into an authenticator app. When the barcode is scanned by the authenticator app. it will generate and display temporary six digit authentication codes. Enter a code from the authenticator app here:
Verify these codes against the secret:
| In[2]:= |
| Out[2]= |
If the authentication code is incorrect or is more then 30 seconds old, the test returns False:
| In[3]:= |
| Out[3]= |
The secret should be stored against the user's account information in your application, and should never be displayed again after initial creation.
A minimal interface that implements two-factor authentication:
| In[4]:= | ![]() |
| Out[5]= |
On first visit, the code is shared:

On second visit, you cannot proceed without an Authentication code:

This work is licensed under a Creative Commons Attribution 4.0 International License