{"_id":"@djthoms/remix-auth-auth0","name":"@djthoms/remix-auth-auth0","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@djthoms/remix-auth-auth0","version":"2.0.0","keywords":["remix","remix-auth","auth","authentication","strategy","auth0"],"homepage":"https://github.com/danestves/remix-auth-auth0#readme","repository":{"type":"git","url":"git+https://github.com/danestves/remix-auth-auth0.git"},"license":"MIT","type":"module","exports":{".":{"import":{"types":"./build/index.d.ts","default":"./build/index.js"},"require":{"types":"./build/index.d.cts","default":"./build/index.cjs"}}},"main":"./build/index.cjs","module":"./build/index.js","types":"./build/index.d.cts","dependencies":{"remix-auth-oauth2":"^2.1.0"},"devDependencies":{"@commitlint/cli":"^19.3.0","@commitlint/config-conventional":"^19.2.2","@djthoms/eslint-config":"^6.4.2","@djthoms/prettier-config":"^4.4.1","@remix-run/node":"^2.10.3","@remix-run/react":"^2.10.3","@remix-run/server-runtime":"^2.10.3","@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@typescript-eslint/eslint-plugin":"^7.16.1","@typescript-eslint/parser":"^7.16.1","@vitest/coverage-v8":"^2.0.3","husky":"^9.0.11","is-ci":"^3.0.1","lint-staged":"^15.2.7","semantic-release":"^23.1.1","tsup":"^8.1.0","typescript":"^5.5.3","vitest":"^2.0.3","vitest-fetch-mock":"^0.3.0"},"peerDependencies":{"@remix-run/server-runtime":"^1.0.0 || ^2.0.0","remix-auth":"^3.0.0"},"engines":{"node":">=18"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup","lint":"eslint --ext .ts,.tsx src/","test":"vitest run","typecheck":"tsc --noEmit"},"_id":"@djthoms/remix-auth-auth0@2.0.0","description":"The Auth0 strategy is used to authenticate users against an Auth0 account. It extends the OAuth2Strategy.","bugs":{"url":"https://github.com/danestves/remix-auth-auth0/issues"},"_integrity":"sha512-Rq42GcQ9+Pp5dC0nR4pqNFrgsjpD0BakV9qub4pkFxcZsC9FUgu3vBcnIBcWD3jdBHRFrd+XU5i+MVCHxDOZDg==","_resolved":"/private/var/folders/1r/tpdydv7j1f7dp71tzch2tppc0000gn/T/9055c324a57efb6d681d3152addc4ef6/djthoms-remix-auth-auth0-2.0.0.tgz","_from":"file:djthoms-remix-auth-auth0-2.0.0.tgz","_nodeVersion":"20.11.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Rq42GcQ9+Pp5dC0nR4pqNFrgsjpD0BakV9qub4pkFxcZsC9FUgu3vBcnIBcWD3jdBHRFrd+XU5i+MVCHxDOZDg==","shasum":"f011804b737ef55ef9ecc4dbdf91c09bede5599b","tarball":"https://registry.npmjs.org/@djthoms/remix-auth-auth0/-/remix-auth-auth0-2.0.0.tgz","fileCount":9,"unpackedSize":33602,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHgLCV6cAaK22LEphMa3Vj6teMzcY24/AKrjktlJQGwyAiEA2YD/lvb+tY7I3sYQJIZZMwK2Y0bUVzGNssMRkoMQceA="}]},"_npmUser":{"name":"djthomps","email":"djtthompson@gmail.com"},"directories":{},"maintainers":[{"name":"djthomps","email":"djtthompson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/remix-auth-auth0_2.0.0_1721182886639_0.7299227582842183"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-17T02:21:26.547Z","2.0.0":"2024-07-17T02:21:26.815Z","modified":"2024-07-17T02:21:27.099Z"},"maintainers":[{"name":"djthomps","email":"djtthompson@gmail.com"}],"description":"The Auth0 strategy is used to authenticate users against an Auth0 account. It extends the OAuth2Strategy.","homepage":"https://github.com/danestves/remix-auth-auth0#readme","keywords":["remix","remix-auth","auth","authentication","strategy","auth0"],"repository":{"type":"git","url":"git+https://github.com/danestves/remix-auth-auth0.git"},"bugs":{"url":"https://github.com/danestves/remix-auth-auth0/issues"},"license":"MIT","readme":"# Auth0Strategy\n\nThe Auth0 strategy is used to authenticate users against an Auth0 account. It\nextends the OAuth2Strategy.\n\n## Supported runtimes\n\n| Runtime    | Has Support |\n| ---------- | ----------- |\n| Node.js    | ✅          |\n| Cloudflare | ✅          |\n\n## Usage\n\n### Create an Auth0 tenant\n\nFollow the steps on\n[the Auth0 documentation](https://auth0.com/docs/get-started/create-tenants) to\ncreate a tenant and get a client ID, client secret and domain.\n\n### Create the strategy instance\n\n```tsx\n// app/utils/auth.server.ts\nimport { Authenticator } from \"remix-auth\";\nimport { Auth0Strategy } from \"remix-auth-auth0\";\n\ntype User = { /* fill in*/ };\n\n// Create an instance of the authenticator, pass a generic with what your\n// strategies will return and will be stored in the session\nexport const authenticator = new Authenticator<User>(sessionStorage);\n\nconst auth0Strategy = new Auth0Strategy(\n  {\n    callbackURL: \"https://example.com/auth/auth0/callback\",\n    clientID: \"YOUR_AUTH0_CLIENT_ID\",\n    clientSecret: \"YOUR_AUTH0_CLIENT_SECRET\",\n    domain: \"YOUR_TENANT.us.auth0.com\",\n  },\n  async ({ tokens: { access_token, scope, expires_in, refresh_token }, profile }) => {\n    // Get the user data from your DB or API using the tokens and profile\n    return User.findOrCreate({ email: profile.emails[0].value });\n  },\n);\n\nauthenticator.use(auth0Strategy);\n```\n\n### Setup your routes\n\n```tsx\n// app/routes/login.tsx\nexport default function Login() {\n  return (\n    <Form action=\"/auth/auth0\" method=\"post\">\n      <button>Login with Auth0</button>\n    </Form>\n  );\n}\n```\n\n```tsx\n// app/routes/auth.auth0.tsx\nimport { redirect, type ActionFunctionArgs } from \"@remix-run/node\";\n\nimport { authenticator } from \"~/utils/auth.server\";\n\nexport const loader = () => redirect(\"/login\");\n\nexport const action = ({ request }: ActionFunctionArgs) => {\n  return authenticator.authenticate(\"auth0\", request);\n};\n```\n\n```tsx\n// app/routes/auth.auth0.callback.tsx\nimport { type LoaderFunctionArgs } from \"@remix-run/node\";\n\nimport { authenticator } from \"~/utils/auth.server\";\n\nexport const loader = ({ request }: LoaderFunctionArgs) => {\n  return authenticator.authenticate(\"auth0\", request, {\n    successRedirect: \"/dashboard\",\n    failureRedirect: \"/login\",\n  });\n};\n```\n\n```tsx\n// app/routes/auth.logout.ts\nimport { redirect, type ActionFunctionArgs } from \"@remix-run/node\";\n\nimport { destroySession, getSession } from \"~/utils/auth.server\";\n\nexport const action = async ({ request }: ActionFunctionArgs) => {\n  const session = await getSession(request.headers.get(\"Cookie\"));\n  const logoutURL = new URL(process.env.AUTH0_LOGOUT_URL); // i.e https://YOUR_TENANT.us.auth0.com/v2/logout\n\n  logoutURL.searchParams.set(\"client_id\", process.env.AUTH0_CLIENT_ID);\n  logoutURL.searchParams.set(\"returnTo\", process.env.AUTH0_RETURN_TO_URL);\n\n  return redirect(logoutURL.toString(), {\n    headers: {\n      \"Set-Cookie\": await destroySession(session),\n    },\n  });\n};\n```\n\n## Advanced Usage\n\n### Link directly to signup\n\n```tsx\n// app/routes/register.tsx\nexport default function Register() {\n  return (\n    <Form action=\"/auth/auth0?screen_hint=signup\" method=\"post\">\n      <button>Register with Auth0</button>\n    </Form>\n  );\n}\n\n// https://auth0.com/docs/authenticate/login/auth0-universal-login/new-experience#signup\n```\n","readmeFilename":"README.md"}