Skip to content

Commit

Permalink
Release v0.6.1 (#167)
Browse files Browse the repository at this point in the history
* update rules.json

* 0.6.1
  • Loading branch information
FadyMak authored and shawnmclean committed Sep 11, 2018
1 parent 9311d24 commit 2b95724
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rules-templates",
"version": "0.6.0",
"version": "0.6.1",
"description": "Auth0 Rules Repository =====",
"main": "./rules",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"categories": [
"access control"
],
"description": "<p> This rule will check that the email the user has used to login matches any of the domains configured in a connection. If there are no domains configured, it will allow access.</p>\n<p> For example, to setup SAML login, a Fabrikam customer must have a managed domain (claimed and verified by the customer). Fabrikam can then enforce a policy where only users belonging to managed email domains should be able to login via SAML. For example, if the customer Contoso has setup contoso.com as a managed domain, only users with email ending @contoso.com (not @contosocorp.com) should be able to login via SAML.\n Because Auth0 doesn&#39;t enforce this validation OOB - we have to store the valid email domain in connection object (lock already uses this) and then use a rule to validate incoming user&#39;s email domain with the one configured on the connection. If email domains doesn&#39;t match, the login is denied.</p>\n",
"code": "function (user, context, callback) {\n const connectionOptions = context.connectionOptions;\n\n // No domains -> access allowed\n if (!connectionOptions.tenant_domain) {\n return callback(null, user, context);\n }\n\n // Access allowed if domain is found\n const userEmailDomain = user.email.split('@')[1].toLowerCase();\n const domainFound = connectionOptions.domain_aliases.some(function (domain) {\n return userEmailDomain === domain;\n });\n\n if (domainFound) return callback(null, user, context);\n\n return callback('Access denied');\n}"
"description": "<p>This rule checks if the user&#39;s login email matches any domains configured in an enterprise connection. If there are no matches, the login is denied. But, if there are no domains configured it will allow access.</p>\n<p>Use this rule to only allow users from specific email domains to login.</p>\n<p>For example, ExampleCo has setup exampleco.com as a managed domain. They add exampleco.com to the email domains list in their SAML connection. Now, only users with an email ending with @exampleco.com (and not @examplecocorp.com) can login via SAML.</p>\n",
"code": "function (user, context, callback) {\n const connectionOptions = context.connectionOptions;\n const domainAliases = connectionOptions.domain_aliases || [];\n const tenantDomain = connectionOptions.tenant_domain;\n\n // No domains -> access allowed\n if (!tenantDomain && !domainAliases.length) {\n return callback(null, user, context);\n }\n\n // Domain aliases exist but no tenant domain exists\n if (domainAliases.length && !tenantDomain) return callback('Access denied');\n\n let allowedDomains = new Set([tenantDomain]);\n domainAliases.forEach(function (alias) {\n if (alias) allowedDomains.add(alias.toLowerCase());\n });\n\n // Access allowed if domain is found\n const userEmailDomain = user.email.split('@')[1].toLowerCase();\n if (allowedDomains.has(userEmailDomain)) return callback(null, user, context);\n\n return callback('Access denied');\n}"
},
{
"id": "check_last_password_reset",
Expand Down

0 comments on commit 2b95724

Please sign in to comment.