Ory Kratos — Cloud-Native Identity and User Management
Ory Kratos is a headless, API-first identity server that handles registration, login, MFA, account recovery, and profile management without bundling a UI, so you keep full control over the user experience.
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install dcb25a5e-3942-11f1-9bc6-00163e2b0d79 --target codex先 dry-run,确认写入项后再运行此命令。
What it is
Ory Kratos is a headless, API-first identity and user management server. It handles registration, login, multi-factor authentication, account recovery, profile management, and session handling without bundling a UI. You build your own frontend and call Kratos APIs, keeping full control over the user experience.
Platform engineers, security teams, and backend developers who need production-grade identity management without vendor lock-in use Kratos. It is part of the Ory ecosystem alongside Hydra (OAuth2), Oathkeeper (API gateway), and Keto (permissions).
How it saves time or tokens
Kratos handles the security-critical parts of identity (password hashing, session tokens, CSRF protection, account enumeration prevention) so developers do not build and maintain these themselves. The self-service flow system covers registration, login, settings, recovery, and verification with configurable identity schemas, reducing custom code.
How to use
- Run Kratos with Docker:
docker run --rm -p 4433:4433 -p 4434:4434 \
-e DSN=memory \
oryd/kratos:latest serve --dev
- Access the public API at
http://localhost:4433and admin API athttp://localhost:4434. - Initiate a registration flow:
curl -s http://localhost:4433/self-service/registration/api | python3 -m json.tool
Example
# Create a registration flow
FLOW=$(curl -s http://localhost:4433/self-service/registration/api)
ACTION=$(echo $FLOW | python3 -c "import sys,json; print(json.load(sys.stdin)['ui']['action'])")
# Submit registration
curl -X POST "$ACTION" \
-H 'Content-Type: application/json' \
-d '{
"method": "password",
"traits": {"email": "user@example.com"},
"password": "secure-password-123"
}'
Related on TokRepo
- AI tools for security — Security and identity tools
- AI tools for self-hosted — Self-hosted infrastructure tools
Common pitfalls
- Kratos is headless, meaning you must build your own login/registration UI. If you want a pre-built UI, check the Ory Account Experience or use the community reference implementations.
- Running Kratos with
--devflag in production. The dev mode disables security features like CSRF and cookie security. Always use proper configuration for production deployments. - Confusing Kratos (identity) with Hydra (OAuth2). Kratos manages users and sessions. Hydra provides OAuth2/OIDC flows. They are separate services that work together.
常见问题
Kratos is self-hosted and open source. Auth0 is a managed SaaS service. Kratos gives you full control over data and UI but requires you to host and operate it. Auth0 handles operations for you but introduces vendor lock-in and per-user pricing.
Yes. Kratos supports social login via OIDC providers including Google, GitHub, Apple, Microsoft, and any standard OIDC-compliant provider. Configure social providers in the Kratos configuration file and they appear as login options in your self-service flows.
Kratos supports TOTP (authenticator apps), WebAuthn (hardware keys and biometrics), and lookup secrets (recovery codes) as second factors. MFA is configured per identity schema and enforced during the login flow. You can require MFA for all users or make it optional.
Yes. Kratos is stateless and stores all data in a database (PostgreSQL, MySQL, CockroachDB, or SQLite). You can run multiple Kratos instances behind a load balancer. Session validation is database-backed, so any instance can validate any session.
Kratos supports PostgreSQL, MySQL, CockroachDB, and SQLite. PostgreSQL is recommended for production deployments. SQLite is suitable for development and testing. The 'memory' DSN runs an in-memory database for quick experimentation.
引用来源 (3)
- Ory Kratos GitHub— Ory Kratos is a headless API-first identity server
- Ory Kratos MFA Docs— Supports TOTP, WebAuthn, and lookup secrets for MFA
- Ory Ecosystem Docs— Part of the Ory ecosystem with Hydra, Oathkeeper, and Keto
讨论
相关资产
Ory Oathkeeper — Cloud Native Identity & Access Proxy
Ory Oathkeeper is an open source Identity and Access Proxy that authenticates, authorizes, and mutates incoming HTTP requests before forwarding them to upstream services, acting as a zero trust gateway.
Rainbond — Cloud-Native Application Platform Without Kubernetes Expertise
Rainbond is an open-source cloud-native application management platform that abstracts away Kubernetes complexity, letting developers deploy, manage, and orchestrate containerized applications through a visual interface without writing YAML.
Quickwit — Cloud-Native Sub-Second Search Engine
Quickwit is a cloud-native search engine built in Rust for log management and distributed search on object storage. It indexes data directly to S3-compatible stores, enabling cost-efficient search at petabyte scale.
Ory Hydra — Open-Source OAuth 2.0 and OpenID Connect Server
Ory Hydra is a hardened, certified OAuth 2.0 and OpenID Connect provider that handles token issuance and consent flows while letting you own user management and login UI.