{"library":"remix-auth-okta","title":"Okta Strategy for Remix Auth","description":"This package provides an authentication strategy for integrating Okta with Remix applications through the `remix-auth` library. It extends the `OAuth2Strategy` to handle Okta's specific OAuth 2.0 and OpenID Connect flows, supporting both Node.js and Cloudflare runtimes. The current stable version is 1.2.0, with updates generally following `remix-auth`'s release cadence and Okta API changes. `remix-auth-okta` enables developers to quickly set up user authentication against an Okta account, managing the redirect to Okta for login and processing the callback. Its key differentiators include tight integration with the `remix-auth` ecosystem, offering a standardized approach to adding Okta authentication, and flexibility to support both Okta's hosted login page and custom login forms within the Remix application.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install remix-auth-okta"],"cli":null},"imports":["import { OktaStrategy } from 'remix-auth-okta';","import { Authenticator } from 'remix-auth';","interface User { id: string; email: string; } export const authenticator = new Authenticator<User>(sessionStorage);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// app/utils/auth.server.ts\nimport { Authenticator } from \"remix-auth\";\nimport { OktaStrategy } from \"remix-auth-okta\";\nimport { createCookieSessionStorage } from \"@remix-run/node\"; // Example for session storage\n\n// Define your user type that will be stored in the session\ninterface AppUser { id: string; email: string; }\n\n// Configure session storage (replace with your actual session setup)\nconst sessionStorage = createCookieSessionStorage({\n  cookie: {\n    name: \"_session\",\n    httpOnly: true,\n    secure: process.env.NODE_ENV === \"production\", // Use secure cookies in production\n    secrets: [process.env.SESSION_SECRET ?? \"s3cr3t\"], // Must provide a secret\n    maxAge: 60 * 60 * 24 * 7, // 7 days\n  },\n});\n\n// Create an instance of the authenticator\nexport const authenticator = new Authenticator<AppUser>(sessionStorage);\n\n// Initialize the Okta Strategy with environment variables\nconst oktaStrategy = new OktaStrategy(\n  {\n    issuer: process.env.OKTA_ISSUER ?? 'YOUR_OKTA_ISSUER_MISSING',\n    clientID: process.env.OKTA_CLIENT_ID ?? 'YOUR_OKTA_CLIENT_ID_MISSING',\n    clientSecret: process.env.OKTA_CLIENT_SECRET ?? 'YOUR_OKTA_CLIENT_SECRET_MISSING',\n    callbackURL: process.env.OKTA_CALLBACK_URL ?? 'http://localhost:3000/auth/okta/callback',\n  },\n  async ({ accessToken, refreshToken, extraParams, profile }) => {\n    // This callback runs after a successful Okta authentication.\n    // Here, you would typically find or create a user in your database\n    // based on the profile information (e.g., profile.email).\n    console.log(\"Okta Profile:\", profile);\n    // Return a user object that will be stored in the session.\n    return { id: profile.id, email: profile.email ?? 'unknown@example.com' };\n  }\n);\n\n// Register the strategy with a unique name (e.g., \"okta\")\nauthenticator.use(oktaStrategy, \"okta\");","lang":"typescript","description":"This quickstart demonstrates the core setup of `remix-auth-okta`. It initializes the `OktaStrategy` using environment variables for sensitive credentials, configures a basic `Authenticator` instance with a session storage, and defines the post-authentication callback to process user profile data from Okta.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}