{"id":29452625,"url":"https://github.com/thilinatlm/vite-plugin-oidc-auth","last_synced_at":"2026-05-19T04:35:11.575Z","repository":{"id":303348006,"uuid":"1015183636","full_name":"ThilinaTLM/vite-plugin-oidc-auth","owner":"ThilinaTLM","description":"A Vite plugin that provides OIDC (OpenID Connect) authentication during development","archived":false,"fork":false,"pushed_at":"2025-07-07T06:19:34.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-07T06:35:22.292Z","etag":null,"topics":["oidc","vitejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThilinaTLM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-07-07T06:09:04.000Z","updated_at":"2025-07-07T06:10:02.000Z","dependencies_parsed_at":"2025-07-07T06:35:28.444Z","dependency_job_id":"4e655a1d-0e72-48ce-b16e-5613aa824fa1","html_url":"https://github.com/ThilinaTLM/vite-plugin-oidc-auth","commit_stats":null,"previous_names":["thilinatlm/vite-plugin-oidc-auth"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ThilinaTLM/vite-plugin-oidc-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThilinaTLM%2Fvite-plugin-oidc-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThilinaTLM%2Fvite-plugin-oidc-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThilinaTLM%2Fvite-plugin-oidc-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThilinaTLM%2Fvite-plugin-oidc-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThilinaTLM","download_url":"https://codeload.github.com/ThilinaTLM/vite-plugin-oidc-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThilinaTLM%2Fvite-plugin-oidc-auth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265213164,"owners_count":23728675,"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":["oidc","vitejs"],"created_at":"2025-07-13T22:09:54.137Z","updated_at":"2026-05-19T04:35:11.536Z","avatar_url":"https://github.com/ThilinaTLM.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-oidc-auth\n\nA Vite plugin that provides OIDC (OpenID Connect) authentication during development. This plugin automatically handles the OAuth flow and injects the access token into your development environment.\n\n## Features\n\n- 🔐 Automatic OIDC authentication flow\n- 🚀 Auto-opens browser for authentication (configurable)\n- 🔑 Injects access token as `import.meta.env.VITE_API_TOKEN`\n- ⚡ Development-only plugin (doesn't affect production builds)\n- 🎯 PKCE support for secure authentication\n- 📁 Flexible environment variable configuration\n\n## Installation\n\n```bash\nnpm install vite-plugin-oidc-auth\n# or\nyarn add vite-plugin-oidc-auth\n# or\npnpm add vite-plugin-oidc-auth\n```\n\n## Usage\n\n### Basic Setup\n\n1. Add the plugin to your `vite.config.js`:\n\n```js\nimport { defineConfig } from 'vite'\nimport oidcAuth from 'vite-plugin-oidc-auth'\n\nexport default defineConfig({\n  plugins: [\n    oidcAuth()\n  ]\n})\n```\n\n2. Create a `.env.local` file with your OIDC configuration:\n\n```env\nOIDC_DISCOVERY_URL=https://your-provider.com/.well-known/openid-configuration\nOIDC_CLIENT_ID=your-client-id\nOIDC_CLIENT_SECRET=your-client-secret\nOIDC_REDIRECT_URI=http://localhost:3001/callback\nOIDC_SCOPE=openid profile email\n```\n\n3. Start your development server:\n\n```bash\nnpm run dev\n```\n\nThe plugin will automatically open your browser to authenticate. After successful authentication, the access token will be available as `import.meta.env.VITE_API_TOKEN` in your application.\n\n### Configuration Options\n\n```js\nimport oidcAuth from 'vite-plugin-oidc-auth'\n\nexport default defineConfig({\n  plugins: [\n    oidcAuth({\n      openBrowser: false, // Disable auto-opening browser\n      envFilePath: '.env.development', // Custom env file path\n      oidcOptions: {\n        // Override environment variables\n        discoveryUrl: 'https://custom-provider.com/.well-known/openid-configuration',\n        clientId: 'custom-client-id',\n        clientSecret: 'custom-client-secret',\n        redirectUri: 'http://localhost:3001/callback',\n        scope: 'openid profile email'\n      }\n    })\n  ]\n})\n```\n\n### Using the Token in Your App\n\n```js\n// Access the token in your application\nconst token = import.meta.env.VITE_API_TOKEN\n\n// Use it in API calls\nfetch('/api/data', {\n  headers: {\n    'Authorization': `Bearer ${token}`\n  }\n})\n```\n\n## Environment Variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `OIDC_DISCOVERY_URL` | Yes | OIDC discovery endpoint URL |\n| `OIDC_CLIENT_ID` | Yes | OAuth client ID |\n| `OIDC_CLIENT_SECRET` | Yes | OAuth client secret |\n| `OIDC_REDIRECT_URI` | Yes | Redirect URI for OAuth callback |\n| `OIDC_SCOPE` | Yes | OAuth scopes (e.g., \"openid profile email\") |\n\n## How It Works\n\n1. When you start the dev server, the plugin creates a temporary HTTP server on the redirect URI\n2. It generates PKCE challenge codes for secure authentication\n3. Opens your browser to the OIDC provider's authorization endpoint\n4. After authentication, the provider redirects to the callback server\n5. The plugin exchanges the authorization code for an access token\n6. The token is injected into your Vite environment as `VITE_API_TOKEN`\n\n## Development Mode Only\n\nThis plugin only runs during development (`vite dev`) and is automatically disabled for production builds. This ensures your authentication flow doesn't interfere with your production application.\n\n## TypeScript Support\n\nThe plugin includes full TypeScript support with exported types:\n\n```ts\nimport oidcAuth, { OidcOptions, OidcPluginOptions } from 'vite-plugin-oidc-auth'\n\nconst options: OidcPluginOptions = {\n  openBrowser: true,\n  oidcOptions: {\n    discoveryUrl: 'https://provider.com/.well-known/openid-configuration',\n    clientId: 'client-id',\n    clientSecret: 'client-secret',\n    redirectUri: 'http://localhost:3001/callback',\n    scope: 'openid profile'\n  }\n}\n\nexport default defineConfig({\n  plugins: [oidcAuth(options)]\n})\n```\n\n## License\n\nMIT\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthilinatlm%2Fvite-plugin-oidc-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthilinatlm%2Fvite-plugin-oidc-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthilinatlm%2Fvite-plugin-oidc-auth/lists"}