{"id":29323837,"url":"https://github.com/edgeflare/ngx-oidc","last_synced_at":"2025-07-07T16:06:40.356Z","repository":{"id":187853587,"uuid":"677710415","full_name":"edgeflare/ngx-oidc","owner":"edgeflare","description":"oidc-client-ts wrapper for Angular and Capacitor","archived":false,"fork":false,"pushed_at":"2025-07-04T01:42:12.000Z","size":2919,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-04T02:33:35.263Z","etag":null,"topics":["android","angular","capacitor","ionic","ios","oauth2","oidc"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edgeflare.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,"zenodo":null}},"created_at":"2023-08-12T11:29:41.000Z","updated_at":"2025-07-04T01:42:16.000Z","dependencies_parsed_at":"2025-07-04T02:43:59.628Z","dependency_job_id":null,"html_url":"https://github.com/edgeflare/ngx-oidc","commit_stats":null,"previous_names":["edgeflare/keycloak-angular-capacitor","edgeflare/ngx-oidc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/edgeflare/ngx-oidc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeflare%2Fngx-oidc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeflare%2Fngx-oidc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeflare%2Fngx-oidc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeflare%2Fngx-oidc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edgeflare","download_url":"https://codeload.github.com/edgeflare/ngx-oidc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgeflare%2Fngx-oidc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263489677,"owners_count":23474526,"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":["android","angular","capacitor","ionic","ios","oauth2","oidc"],"created_at":"2025-07-07T16:06:39.694Z","updated_at":"2025-07-07T16:06:40.343Z","avatar_url":"https://github.com/edgeflare.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [oidc-client-ts](https://github.com/authts/oidc-client-ts) wrapper for Angular and Capacitor\n\n![signin demo](https://raw.githubusercontent.com/edgeflare/ngx-oidc/main/demo.gif?raw=true)\n\n## 1. Install\n```shell\nnpm install oidc-client-ts @edgeflare/ngx-oidc\n```\n\n## 2. Configure Angular\nUpdate `\u003capproot\u003e/src/app/app.config.ts`. The [example](https://github.com/edgeflare/ngx-oidc/tree/main/example) directory includes a minimal app.\n\n```ts\nimport { ApplicationConfig } from '@angular/core';\nimport { provideRouter, Route } from '@angular/router';\nimport { UserManagerSettings } from 'oidc-client-ts';\nimport { initOidc, OIDC_ROUTES } from '@edgeflare/ngx-oidc';\n\n// Define OIDC configuration\nconst oidcConfig: UserManagerSettings = {\n  authority: \"http://127.0.0.1:5556/dex\",\n  client_id: \"public-webui\",\n  redirect_uri: \"http://localhost:4200/signin/callback\",\n  response_type: \"code\",\n  scope: \"openid profile email offline_access audience:server:client_id:oauth2-proxy\", // extra scopes for Dex\n  post_logout_redirect_uri: \"http://localhost:4200/signout/callback\",\n  automaticSilentRenew: true,\n  silentRequestTimeoutInSeconds: 30,\n  silent_redirect_uri: \"http://localhost:4200/silent-refresh-callback.html\",\n};\n\n// Provide OIDC configuration and routes in the application configuration\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    // other providers\n    ...initOidc(oidcConfig),\n    provideRouter(OIDC_ROUTES), // before application routes\n    provideRouter(routes)\n    // more providers\n  ],\n};\n```\n\n**For [Capacitor](https://github.com/ionic-team/capacitor) based native mobile apps**\n\n```sh\nnpm install @capacitor/core oidc-client-ts @edgeflare/ngx-oidc @edgeflare/ngx-oidc-capacitor\n```\n\n```ts\nimport { UserManagerSettings, WebStorageStateStore } from 'oidc-client-ts';\nimport { initOidc, OIDC_ROUTES, CapacitorStateStore } from '@edgeflare/ngx-oidc-capacitor';\nimport { Capacitor } from '@capacitor/core';\n\nconst oidcConfig: UserManagerSettings | any = {\n  // Android requires issuer/authority endpoint to be HTTPS\n  authority: 'https://iam.example.org', // https://keycloak.example.org/realms/\u003crealmname\u003e\n  client_id: 'public-webui',\n  redirect_uri: Capacitor.isNativePlatform()\n    ? 'org.example.capdemo://signin/callback'\n    : `${window.location.origin}/signin/callback`,\n  post_logout_redirect_uri: Capacitor.isNativePlatform()\n    ? 'org.example.capdemo://signout/callback'\n    : `${window.location.origin}/signout/callback`,\n  response_type: 'code',\n  scope: 'openid profile email offline_access audience:server:client_id:oauth2-proxy',\n  automaticSilentRenew: true,\n  // Use the appropriate storage based on platform\n  userStore: Capacitor.isNativePlatform()\n    ? new CapacitorStateStore() // consider github.com/martinkasa/capacitor-secure-storage-plugin for sensitive (eg banking) apps\n    : new WebStorageStateStore({\n      store: window.localStorage\n    }),\n  loadUserInfo: true,\n};\n```\n\nIf using Capacitor, ensure all imports are from `@edgeflare/ngx-oidc-capacitor`, instead of `@edgeflare/ngx-oidc`. See [example-capacitor](./example-capacitor) app.\n\n*Providing* `OIDC_ROUTES` registers below routes:\n\n- `/signin/{callback,error,''}`\n- `/signout/callback`\n- `/oidc-profile`, protected by an `authGuard` supplied with `ngx-oidc`\n\nSee `signinRedirect`, `signinPopup` etc examples at [http://localhost:4200/signin](http://localhost:4200/signin). It additionally provides `user` and `isAuthenticated` signals; which can be called like `user()` to get the current user, and `isAuthenticated()` to check if the user is authenticated.\n\nThe routes can be registered on parent routes other root `/`, with ngx-oidc supplied components or your own.\n\n```ts\nconst myOidcRoutes: Route[] = [\n  // signin is now at /account/signin\n  { path: 'account', loadChildren: () =\u003e import(\"@edgeflare/ngx-oidc\").then((m) =\u003e m.OIDC_ROUTES)},\n  // Or just the only required route. must match the `redirect_uri` in oidcConfig\n  { path: 'signin-callback', loadComponent: () =\u003e import(\"@edgeflare/ngx-oidc\").then((m) =\u003e m.SigninCallbackComponent)},\n];\n\n// ...\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    ...initOidc(oidcConfig),\n    provideRouter(myOidcRoutes),\n  ],\n};\n```\n\n## Features\n- [x] signinRedirect, signinPopup, signoutRedirect, signoutPopup\n- [x] authGuard using canActivateFn\n- [x] [Capactior](https://github.com/ionic-team/capacitor) support for native mobile apps\n\n## Contributing / Development\n\nWith ~200 lines of code ngx-oidc doesn't really do much except calling oidc-client-ts functions. It sets up and exposes oidc-client-ts' [UserManager](https://authts.github.io/oidc-client-ts/classes/UserManager.html) functions through an Angular service, AuthService. The function signatures used in this service are the same as those provided by `oidc-client-ts` *e.g.*:\n\n- `signinRedirect(args?: SigninRedirectArgs): Promise\u003cvoid\u003e`\n- `signinPopup(args?: SigninPopupArgs): Promise\u003cUser\u003e`\n- `signinSilent(args?: SigninSilentArgs): Promise\u003cnull | User\u003e`\n\nFor advanced usage, access the underlying oidc-client-ts' UserManager instance with `AuthService.userManagerInstance`. If you wanna make it better, please do! Fork the repo, make your changes, and submit a PR.\n\n```sh\nnpx ng build ngx-oidc\nnpx ng build ngx-oidc-capacitor\n```\n\n## License\nApache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgeflare%2Fngx-oidc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedgeflare%2Fngx-oidc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgeflare%2Fngx-oidc/lists"}