One-time PIN login
Cloudflare Access can send a one-time PIN (OTP) to approved email addresses as an alternative to integrating an identity provider. You can simultaneously configure OTP login and the identity provider of your choice to allow users to select their own authentication method.
For example, if your team uses Okta but you are collaborating with someone outside your organization, you can use OTP to grant access to guests.
- In Zero Trust ↗, go to Settings > Authentication.
- Under Login methods, select Add new.
- Select One-time PIN.
-
Create an API token with the following permissions:
Type Item Permission Account Access: Organizations, Identity Providers, and Groups Edit -
Make a
POST
request to the Identity Providers endpoint:Terminal window curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/identity_providers \--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \--data '{"name": "One-time PIN login","type": "onetimepin","config": {}}'
-
Add the following permission to your
cloudflare_api_token
↗:Access: Organizations, Identity Providers, and Groups Write
-
Configure the
cloudflare_zero_trust_access_identity_provider
↗ resource:resource "cloudflare_zero_trust_access_identity_provider" "onetimepin_login" {account_id = var.cloudflare_account_idname = "One-time PIN login"type = "onetimepin"}
To grant a user access to an application, simply add their email address to an Access policy.
To log in to Access using the one-time PIN:
- Go to the application protected by Access.
- On the Access login page, enter your email address and select Send me a code.
- If the email is allowed by an Access policy, you will receive a PIN in your inbox. This secure PIN expires 10 minutes after the initial request.
-
Paste the PIN into the Access login page and select Sign in.
- If the code was valid, you will be redirected to the application.
- If the code was invalid, you will see That account does not have access.