{"id":18867941,"url":"https://github.com/hodfords-solutions/nestjs-oidc","last_synced_at":"2025-08-19T08:32:26.746Z","repository":{"id":257801368,"uuid":"834783711","full_name":"hodfords-solutions/nestjs-oidc","owner":"hodfords-solutions","description":"The NestJS OIDC provider implementation","archived":false,"fork":false,"pushed_at":"2024-10-06T07:47:59.000Z","size":1733,"stargazers_count":43,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-09T19:52:17.816Z","etag":null,"topics":["nestjs","nodejs","oidc","oidc-provider","typescript"],"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/hodfords-solutions.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}},"created_at":"2024-07-28T10:55:50.000Z","updated_at":"2024-10-06T07:48:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f7b61f8-58c1-4a39-8abe-8024ba8936d1","html_url":"https://github.com/hodfords-solutions/nestjs-oidc","commit_stats":null,"previous_names":["hodfords-solutions/nestjs-oidc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodfords-solutions%2Fnestjs-oidc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodfords-solutions%2Fnestjs-oidc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodfords-solutions%2Fnestjs-oidc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodfords-solutions%2Fnestjs-oidc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hodfords-solutions","download_url":"https://codeload.github.com/hodfords-solutions/nestjs-oidc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230340130,"owners_count":18211162,"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":["nestjs","nodejs","oidc","oidc-provider","typescript"],"created_at":"2024-11-08T05:11:55.924Z","updated_at":"2024-12-18T21:09:06.627Z","avatar_url":"https://github.com/hodfords-solutions.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://opensource.hodfords.uk\" target=\"blank\"\u003e\u003cimg src=\"https://opensource.hodfords.uk/img/logo.svg\" width=\"320\" alt=\"Hodfords Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nNestJS-OIDC is easy way to turn our server as oidc provider with minimum configuratiohn\n\n## Installation\nThis package is using redis as adapter to store authentication session and relevant stuffs, so you need to have install redis first\n\n### Register module\nThis is setup to register essential configuration for OIDC provider such as (client, ttls, cookies,...). You can get more at [OIDC Provider](https://github.com/panva/node-oidc-provider/tree/main/docs)\n\n```ts\nimport { OidcModule as NestOidc, OIDC_ACCOUNT_SERVICE } from '@hodfords/nestjs-oidc';\n\n@Module({\n    imports: [\n        NestOidc.forRootAsync({\n            configuration: {\n                useFactory: async function () {\n                    return {\n                        issuer: `${env.BACKEND_URL}/oidc`,\n                        claims: {\n                            email: ['email', 'email_verified'],\n                            profile: ['name'],\n                            groups: ['groups']\n                        },\n                        ttl: {\n                            AccessToken: 5 * 60, // 5 minutes\n                            AuthorizationCode: 60 * 10, // 10 minutes\n                            IdToken: 60 * 60, // 1 hour\n                            RefreshToken: 60 * 60 * 24 * 1, // 1 day\n                            Interaction: 60 * 60, // 1 hour\n                            Session: 60 * 60 * 24 * 14, // 14 days\n                            Grant: 5 * 60 // 5 minutes\n                        },\n                        jwks: {\n                            keys: [env.OIDC_PROVIDER.JWKS]\n                        },\n                        conformIdTokenClaims: false,\n                        cookies: {\n                            keys: ['interaction', 'session', 'state'],\n                            long: {\n                                signed: true,\n                                httpOnly: true,\n                                secure: true, // this should be false at local\n                                sameSite: 'none',\n                                path: '/',\n                                domain: 'localhost'\n                            },\n                            short: {\n                                signed: true,\n                                httpOnly: true,\n                                secure: true, // this should be false at local\n                                sameSite: 'none',\n                                path: '/',\n                                domain: 'localhost'\n                            },\n                            names: {\n                                session: '_session',\n                                interaction: '_interaction',\n                                resume: '_resume',\n                                state: '_state'\n                            }\n                        }\n                    }\n                },\n                imports: [],\n                inject: []\n            },\n            redisHost: `redis://${env.REDIS_HOST}:${env.REDIS_PORT}/${env.REDIS_DB}`,\n            customInteractionUrl: 'http://localhost:3000'\n        }),\n    ],\n    providers: [\n        {\n            provide: OIDC_ACCOUNT_SERVICE,\n            useClass: OidcService\n        },\n    ],\n})\n```\n\n### Define OidcService\nBasically this service will be responsible for retrieving account information that will be returned by OIDC  Provider to 3rd party\n\n```ts\nimport { IAccount } from '@hodfords/nestjs-oidc';\nimport { AccountClaimsType } from '@hodfords/nestjs-oidc/types/account.type';\n\n@Injectable()\nexport class OidcService {\n    async findAccount(ctx: any, id: string): Promise\u003cIAccount\u003e {\n        const account = await this.userService.findById(id);\n        return this.getAccountInfo(account);\n    }\n\n    private async getAccountInfo(account: UserEntity): Promise\u003cIAccount\u003e {\n        return {\n            accountId: account.id,\n            async claims(): Promise\u003cAccountClaimsType\u003e {\n                return snakecaseKeys({\n                    sub: account.id,\n                    email: account.email,\n                    name: account.fullName,\n                    emailVerified: true,\n                    groups: []\n                });\n            }\n        };\n    }\n}\n```\n\nThat is all you need to do to setup OIDC provider with NestJS-OIDC, you can now start your server and access to `http://localhost:3000/oidc/.well-known/openid-configuration` to see the configuration of OIDC provider\n\n## License\n\nNestJS-OIDC is [MIT licensed](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhodfords-solutions%2Fnestjs-oidc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhodfords-solutions%2Fnestjs-oidc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhodfords-solutions%2Fnestjs-oidc/lists"}