{"id":21175158,"url":"https://github.com/giuseppegrieco/loopback4-kratos","last_synced_at":"2026-04-24T20:02:05.327Z","repository":{"id":65071977,"uuid":"537937908","full_name":"giuseppegrieco/loopback4-kratos","owner":"giuseppegrieco","description":"A simple Ory Kratos integration in loopback4 applications","archived":false,"fork":false,"pushed_at":"2022-12-25T23:56:59.000Z","size":313,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T00:56:08.991Z","etag":null,"topics":["kratos","loopback4","loopback4-kratos"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giuseppegrieco.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}},"created_at":"2022-09-17T21:48:09.000Z","updated_at":"2022-12-25T09:48:49.000Z","dependencies_parsed_at":"2022-12-29T21:47:25.772Z","dependency_job_id":null,"html_url":"https://github.com/giuseppegrieco/loopback4-kratos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/giuseppegrieco/loopback4-kratos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppegrieco%2Floopback4-kratos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppegrieco%2Floopback4-kratos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppegrieco%2Floopback4-kratos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppegrieco%2Floopback4-kratos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giuseppegrieco","download_url":"https://codeload.github.com/giuseppegrieco/loopback4-kratos/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppegrieco%2Floopback4-kratos/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32238748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["kratos","loopback4","loopback4-kratos"],"created_at":"2024-11-20T16:57:19.356Z","updated_at":"2026-04-24T20:02:05.306Z","avatar_url":"https://github.com/giuseppegrieco.png","language":"TypeScript","funding_links":[],"categories":["Projects"],"sub_categories":["Ory Kratos"],"readme":"# loopback4-kratos\n[![NodeJS package](https://github.com/giuseppegrieco/loopback4-kratos/actions/workflows/npm.yml/badge.svg?branch=main)](https://github.com/giuseppegrieco/loopback4-kratos/actions/workflows/npm.yml)\n\nA simple Ory Kratos integration in loopback4 applications.\n\n[![LoopBack](\u003chttps://github.com/loopbackio/loopback-next/raw/master/docs/site/imgs/branding/Powered-by-LoopBack-Badge-(blue)-@2x.png\u003e)](http://loopback.io/)\n\n## Installation\n\nInstall KratosComponent using `npm`;\n\n```sh\n$ [npm install | yarn add] loopback4-kratos\n```\n\n## Basic Use\n\n```ts\nimport {AuthenticationComponent} from '@loopback/authentication';\n\nimport {\n  KratosComponentBindings,\n  KratosComponent,\n} from 'loopback4-kratos';\n\n// ...\n\nexport class MyApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(AuthenticationComponent);\n\n    this.component(KratosComponent);\n    this.bind(KratosComponentBindings.CONFIG).to({\n      baseUrl: 'http://kratos_url'\n    });\n    \n    // To register a custom user service\n    this.bind(KratosComponentBindings.USER_SERVICE.key).toClass(\n      MyUserService\n    );\n\n    // ...\n  }\n\n  // ...\n}\n```\n\nIt is therefore necessary to define a new user service:\n```ts\nimport {UserProfile} from '@loopback/security';\n\nimport {\n  KratosUserService\n} from 'loopback4-kratos';\nimport {Session} from '@ory/kratos-client';\n\n// ...\n\nexport class MyUserService extends KratosUserService {\n  convertToUserProfile(response: Session): UserProfile {\n    const ans = super.convertToUserProfile(response);\n    \n    // Implement your strategy ...\n    \n    return ans;\n  }\n\n  // ...\n}\n```\n\nAfter this, you can just use Kratos as authentication strategy across application.\n\n```ts\nimport {authenticate} from '@loopback/authentication';\nimport {get} from '@loopback/rest';\n\n// ...\n\nexport class YourController {\n  @get('/foo')\n  @authenticate('kratos')\n  foo() {\n    // this request is protected by kratos authentication\n  }\n\n  // ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiuseppegrieco%2Floopback4-kratos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiuseppegrieco%2Floopback4-kratos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiuseppegrieco%2Floopback4-kratos/lists"}