{"id":14989796,"url":"https://github.com/patkub/auth0-rule-as-action","last_synced_at":"2026-02-14T11:05:23.066Z","repository":{"id":249464400,"uuid":"831521556","full_name":"patkub/auth0-rule-as-action","owner":"patkub","description":"Experimental NPM package to run an Auth0 Rule as an Action.","archived":false,"fork":false,"pushed_at":"2025-03-02T16:12:54.000Z","size":123,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T12:28:12.798Z","etag":null,"topics":["auth0","auth0-actions","auth0-rules"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/auth0-rule-as-action","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patkub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-20T19:58:23.000Z","updated_at":"2025-03-02T16:12:57.000Z","dependencies_parsed_at":"2025-03-29T12:37:23.390Z","dependency_job_id":null,"html_url":"https://github.com/patkub/auth0-rule-as-action","commit_stats":{"total_commits":53,"total_committers":1,"mean_commits":53.0,"dds":0.0,"last_synced_commit":"20786749738b4f726066e2e9e6838e0fc571871a"},"previous_names":["patkub/auth0-rule-as-action"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patkub%2Fauth0-rule-as-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patkub%2Fauth0-rule-as-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patkub%2Fauth0-rule-as-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patkub%2Fauth0-rule-as-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patkub","download_url":"https://codeload.github.com/patkub/auth0-rule-as-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249785888,"owners_count":21325559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth0","auth0-actions","auth0-rules"],"created_at":"2024-09-24T14:18:55.556Z","updated_at":"2026-02-14T11:05:23.061Z","avatar_url":"https://github.com/patkub.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# auth0-rule-as-action\n\nRun an Auth0 Rule as an Action\n\n📦 NPM: https://www.npmjs.com/package/auth0-rule-as-action\n\n## How this works\n\nThis library can be used in an Auth0 Post-Login action to run old Rules as Actions.\n\nThe basic workflow is as follows:\n\n- Derives old user and context objects from the event object\n- Runs the rule, which mutates the context object\n- Makes api calls based on changes to the context object\n\n## Example\n\n### Add as dependency to a Post Login action\n\n```\nauth0-rule-as-action@latest\n```\n\n### Example Post Login action\n\n```javascript\nconst RuleToAction = require(\"auth0-rule-as-action\");\n\n/**\n * The Rule\n */\nfunction accessOnWeekdaysOnly(user, context, callback) {\n  if (context.clientName === \"All Applications\") {\n    const date = new Date();\n    const d = date.getDay();\n\n    if (d === 0 || d === 6) {\n      return callback(\n        new UnauthorizedError(\"This app is available during the week\"),\n      );\n    }\n  }\n\n  callback(null, user, context);\n}\n\n/**\n * Handler that will be called during the execution of a PostLogin flow.\n *\n * @param {Event} event - Details about the user and the context in which they are logging in.\n * @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.\n */\nexports.onExecutePostLogin = async (event, api) =\u003e {\n  const rule = accessOnWeekdaysOnly;\n  // Instantiate a Rule to Action converter\n  const converter = new RuleToAction(api);\n  // Run the Rule as an Action\n  await converter.convert(event, rule);\n};\n```\n\n## Options\n\nPass in custom methods for conversion process.\n\n```javascript\nconst converter = new RuleToAction(api);\nawait converter.convert(event, rule, {\n  // Rule callback() method\n  callback: converter.defaultRuleCallback,\n  // Maps Post-Login action Event variables to Rules Context variables\n  mapEventToContext: converter.mapEventToContext,\n});\n```\n\n## Currently supported features\n\n- `callback` method with success and error\n- Secrets\n- Redirect urls\n- ID and Access token claims\n- SAML configuration mappings and settings\n- Multifactor triggering\n\n```diff\n-return callback(new UnauthorizedError(\"This app is unavailable\"));\n+api.access.deny(\"This app is unavailable\");\n\n-context.redirect = { url: \"https://example.com/foo\" };\n+api.redirect.sendUserTo(\"https://example.com/foo\");\n\n-context.idToken[\"claim\"] = \"value\";\n+api.idToken.setCustomClaim(claim, value);\n\n-context.accessToken[\"claim\"] = \"value\";\n+api.accessToken.setCustomClaim(claim, value);\n\n-context.samlConfiguration.mappings[\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier\"] = \"upn\";\n+api.samlResponse.setAttribute(\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier\", \"upn\");\n\n-context.samlConfiguration.lifetimeInSeconds = 3600;\n+api.samlResponse.setLifetimeInSeconds(3600);\n...\n\n-context.multifactor = { provider: \"any\", allowRememberBrowser: false };\n+api.multifactor.enable(\"any\", { allowRememberBrowser: false });\n```\n\n## Docs\n\n- Explanation of available [npm scripts](./docs/scripts.md).\n- See [more examples](./docs/examples.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatkub%2Fauth0-rule-as-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatkub%2Fauth0-rule-as-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatkub%2Fauth0-rule-as-action/lists"}