Keycloak — Open Source Identity & Access Management
Keycloak is the most widely deployed open-source IAM solution. SSO, OIDC, SAML, LDAP federation, MFA, social login, and user management for enterprise applications.
这个资产会安全暂存
这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。
npx -y tokrepo@latest install 2d385875-34c8-11f1-9bc6-00163e2b0d79 --target codex先暂存文件;激活前需要读取暂存 README 和安装计划。
What it is
Keycloak is the most widely deployed open-source identity and access management (IAM) solution. It provides single sign-on (SSO), OpenID Connect (OIDC), SAML 2.0, LDAP/Active Directory federation, multi-factor authentication (MFA), social login, and comprehensive user management.
Keycloak targets organizations that need centralized authentication for multiple applications. Instead of implementing auth separately in each app, Keycloak acts as an identity broker that handles login, session management, and authorization across your entire application portfolio.
How it saves time or tokens
Implementing authentication from scratch requires handling password hashing, session tokens, OAuth flows, MFA, and account recovery. Keycloak provides all of this out of the box. Adding a new application to your SSO takes minutes instead of days. LDAP federation lets you connect existing corporate directories without migrating users. Social login (Google, GitHub, Facebook) comes pre-configured.
How to use
- Start Keycloak with Docker:
docker run -d --name keycloak -p 8080:8080 \
-e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:latest start-dev
- Open
http://localhost:8080, log in to the Admin Console.
- Create a realm, register a client application, and configure your auth flow.
Example
// Integrating a Node.js app with Keycloak using OIDC
const express = require('express');
const session = require('express-session');
const Keycloak = require('keycloak-connect');
const memoryStore = new session.MemoryStore();
const app = express();
app.use(session({
secret: 'my-secret',
resave: false,
saveUninitialized: true,
store: memoryStore
}));
const keycloak = new Keycloak({ store: memoryStore }, {
realm: 'my-realm',
'auth-server-url': 'http://localhost:8080/',
resource: 'my-app',
'confidential-port': 0
});
app.use(keycloak.middleware());
app.get('/protected', keycloak.protect(), (req, res) => {
res.json({ message: 'Authenticated', user: req.kauth.grant.access_token.content });
});
app.listen(3000);
Related on TokRepo
- AI Tools for Security — Security tools for authentication and authorization
- Self-Hosted Tools — Self-hosted infrastructure components
This tool integrates with standard development workflows and requires minimal configuration to get started. It is available as open-source software with documentation and community support through the official repository. The project follows semantic versioning for stable releases.
For teams evaluating this tool, the key advantage is reducing manual work in repetitive tasks. The automation provided by the built-in features means less custom code to maintain and fewer integration points to manage. This translates directly to lower maintenance costs and faster iteration cycles.
Common pitfalls
- The
start-devcommand disables HTTPS and uses an in-memory database; for production, usestartwith a PostgreSQL or MySQL database and TLS certificates. - Keycloak's admin console is powerful but complex; invest time learning realms, clients, and identity providers before configuring production auth flows.
- Token expiration defaults may not suit your application; configure access token and session lifetimes in the realm settings to balance security and user experience.
常见问题
Keycloak supports OpenID Connect (OIDC), SAML 2.0, and OAuth 2.0. It can act as both an identity provider and a broker for external identity providers. Most modern applications use OIDC for integration.
Yes. Keycloak provides LDAP and Active Directory federation, allowing you to import and sync users from existing corporate directories without migrating them. Users authenticate against the directory through Keycloak.
Yes. Keycloak supports TOTP (Google Authenticator), WebAuthn (hardware keys), and SMS-based verification. MFA can be required globally, per-realm, or per-client application.
Yes. Keycloak is open-source under the Apache 2.0 license. Red Hat offers a supported commercial version called Red Hat build of Keycloak (formerly Red Hat SSO) for enterprises that need vendor support.
Keycloak supports clustered deployments with session replication across multiple instances. It uses Infinispan for distributed caching and can be deployed on Kubernetes with the Keycloak Operator for automated scaling.
引用来源 (3)
- Keycloak Official Site— Keycloak provides SSO, OIDC, SAML, LDAP federation, and MFA
- Keycloak GitHub— Keycloak is open-source under Apache 2.0 license
- Keycloak Documentation— Keycloak supports clustered deployments with Infinispan caching
讨论
相关资产
Authentik — Open Source Identity Provider & SSO Platform
Authentik is a flexible open-source identity provider with SSO, MFA, user enrollment flows, and application proxy — the authentication glue for your self-hosted stack.
Pomerium — Identity-Aware Zero Trust Access Proxy
Pomerium is an open source reverse proxy that provides secure, identity-aware access to internal applications without a VPN, implementing BeyondCorp-style zero trust networking with SSO integration.
Zitadel — Open Source Identity Infrastructure
Zitadel is an open-source identity management platform with OIDC, SAML, SSO, MFA, passkeys, and multi-tenancy — built for cloud-native apps and enterprise needs.
Ghostfolio — Open Source Wealth Management & Portfolio Tracker
Ghostfolio is an open-source personal finance dashboard for tracking stocks, ETFs, crypto, and other investments with real-time market data and performance analytics.