Skills2026年4月10日·1 分钟阅读

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 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 29/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Stage only
信任
信任等级:Established
入口
step-1.md
安全暂存命令
npx -y tokrepo@latest install 2d385875-34c8-11f1-9bc6-00163e2b0d79 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
Keycloak provides SSO, OIDC, SAML, MFA, and user management as a self-hosted identity platform.
§01

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.

§02

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.

§03

How to use

  1. 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
  1. Open http://localhost:8080, log in to the Admin Console.
  1. Create a realm, register a client application, and configure your auth flow.
§04

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);
§05

Related on TokRepo

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.

§06

Common pitfalls

  • The start-dev command disables HTTPS and uses an in-memory database; for production, use start with 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.

常见问题

What protocols does Keycloak support?+

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.

Can Keycloak connect to Active Directory or LDAP?+

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.

Does Keycloak support multi-factor authentication?+

Yes. Keycloak supports TOTP (Google Authenticator), WebAuthn (hardware keys), and SMS-based verification. MFA can be required globally, per-realm, or per-client application.

Is Keycloak free for commercial use?+

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.

How does Keycloak handle high availability?+

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)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产