-
// from https://github.com/getlarge/nestjs-ory-integration/blob/main/packages/kratos-client-wrapper/src/lib/ory-authentication.guard.ts // ... export const OryAuthenticationGuard = ( options: Partial = defaultOptions ): Type => { @Injectable() class AuthenticationGuard implements CanActivate { readonly logger = new Logger(AuthenticationGuard.name); constructor(readonly oryService: OryFrontendService) {} async canActivate(context: ExecutionContext): Promise { const { cookieResolver, sessionTokenResolver, isValidSession, postValidationHook, } = { ...defaultOptions, ...options, }; try { const cookie = cookieResolver(context); const xSessionToken = sessionTokenResolver(context); const { data: session } = await this.oryService.toSession({ cookie, xSessionToken, }); if (!isValidSession(session)) { return false; } if (typeof postValidationHook === 'function') { await postValidationHook.bind(this)(context, session); } return true; } catch (error) { this.logger.error(error); return false; } } } return mixin(AuthenticationGuard); };
-
Sevalla
Deploy and host your apps and databases, now with $50 credit! Sevalla is the PaaS you have been looking for! Advanced deployment pipelines, usage-based pricing, preview apps, templates, human support by developers, and much more!
-
Ory Kratos
Headless cloud-native authentication and identity management written in Go. Scales to a billion+ users. Replace Homegrown, Auth0, Okta, Firebase with better UX and DX. Passkeys, Social Sign In, OIDC, Magic Link, Multi-Factor Auth, SMS, SAML, TOTP, and more. Runs everywhere, runs best on Ory Network. (by ory)
kratos-client-wrapper is a set of NestJS modules that wraps @ory/client and, more particularly, the Frontend and Identity APIs, which are part of Ory Kratos
-
Nest
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript π
Ory offers excellent documentation but needs more support tools and in-depth examples of using its libraries in TypeScript and NestJS projects. I decided to contribute to it by creating a set of libraries to interact with APIs, which will (hopefully) make integration into your NestJS project easier. This post presents the ideal use case to divulge my routines for creating libraries in NestJS/Nx!
-
Ory Keto
The most scalable and customizable permission server on the market. Fix your slow or broken permission system with Google's proven "Zanzibar" approach. Supports ACL, RBAC, and more. Written in Go, cloud native, headless, API-first. Available as a service on Ory Network and for self-hosters.
keto-client-wrapper is also a set of NestJS modules that wraps @ory/client's Permission and Relationship APIs, which are part of Ory Keto
-
keto-relations-parser is a node library that allows manipulating relations tuples using Ory Permission Language notation. This library is an improved version of this existing lib.
-
Now, letβs focus on the Ory API integration. Ory already provides an auto-generated client based on their Open API specifications, which uses axios under the hood to send HTTP requests. How can we make this an even better experience for NestJS users? I would say:
-
Replace Antlr4 based parser with a simpler and more efficient Regex parser (it still needs to be tested in some edge cases)
-
InfluxDB
InfluxDB β Built for High-Performance Time Series Workloads. InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
Related posts
-
Immich β Cursed Knowledge
-
Scalable REST API Architecture with NestJS, Prisma, Swagger, & Docker: How To.
-
Hacktoberfest for Low or No-Code Professionals: Contribute to OSS Projects
-
Hacktoberfest 2024 with Ghostfolio
-
Encapsulating the Past: How We Tamed a Legacy System with Timeless Software Engineering Principles