Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion main/config/navigation/authenticate.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"docs/authenticate/passwordless/passwordless-with-universal-login",
"docs/authenticate/passwordless/passwordless-connection-limitations",
"docs/authenticate/passwordless/best-practices",
"docs/authenticate/passwordless/sample-use-cases-rules"
"docs/authenticate/passwordless/sample-use-cases-actions"
]
},
{
Expand Down
8 changes: 6 additions & 2 deletions main/config/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -15421,11 +15421,15 @@
},
{
"source": "/docs/connections/passwordless/sample-use-cases-rules",
"destination": "/docs/authenticate/passwordless/sample-use-cases-rules"
"destination": "/docs/authenticate/passwordless/sample-use-cases-actions"
},
{
"source": "/docs/connections/passwordless/concepts/sample-use-cases-rules",
"destination": "/docs/authenticate/passwordless/sample-use-cases-rules"
"destination": "/docs/authenticate/passwordless/sample-use-cases-actions"
},
{
"source": "/docs/authenticate/passwordless/sample-use-cases-rules",
"destination": "/docs/authenticate/passwordless/sample-use-cases-actions"
},
{
"source": "/docs/connections/social/line",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
description: Explore examples using Actions with passwordless connections.
title: Sample Use Cases - Actions with Passwordless Authentication
---

With [Actions](/docs/customize/actions/actions-overview), you can handle more complicated cases than is possible with [passwordless connections](/docs/authenticate/passwordless) alone. For instance, you can add extra precautions to further ensure possession of an email address or device.

## Require Multi-factor Authentication for users who are outside the corporate network
Comment thread
avanscoy marked this conversation as resolved.
Outdated

Let's say you want to require [multi-factor authentication (MFA)](/docs/secure/multi-factor-authentication) for any users who are accessing the application using a <Tooltip tip="Passwordless: Form of authentication that does not rely on a password as the first factor." cta="View Glossary" href="/docs/glossary?term=passwordless">passwordless</Tooltip> connection from outside your corporate network.

Using an Action, you can check whether a user is authenticating using a passwordless method (`sms`, `email`) and if their session IP falls outside of the designated corporate network, prompt them for a second authentication factor.

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">

You could also trigger this Action based on other criteria, such as whether the current IP matches the user's IP allowlist or whether geolocating the user reveals they are in a different country from the one listed in their user profile.

</Callout>
Comment thread
avanscoy marked this conversation as resolved.
Outdated

To do this, [create a Post-Login Action](/docs/customize/actions/write-your-first-action) with the following code. Before deploying, add `ipaddr.js` as an npm dependency in the Action editor.

```javascript lines

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we may want to add something like, "in the provider configuration, add" so it doesn't just jump into code for them

const ipaddr = require('ipaddr.js');

exports.onExecutePostLogin = async (event, api) => {
const corp_network = "192.168.1.134/26";
Comment thread
avanscoy marked this conversation as resolved.
Outdated
const current_ip = ipaddr.parse(event.request.ip);
// is auth method passwordless and IP outside corp network?
const passwordlessOutside = event.authentication.methods.find(
(method) => (
((method.name === 'sms') || (method.name === 'email')) &&
(!current_ip.match(ipaddr.parseCIDR(corp_network)))
)
);

// if yes, then require MFA
if (passwordlessOutside) {
Comment thread
nick-gagliardi marked this conversation as resolved.
Outdated
api.multifactor.enable('any', { allowRememberBrowser: false });
}
};
```
58 changes: 0 additions & 58 deletions main/docs/authenticate/passwordless/sample-use-cases-rules.mdx

This file was deleted.

Loading