什么是Keycloak的OAuth2 / OpenID Connect端点?

时间:2015-02-22 14:08:52

标签: keycloak

我们正在尝试将Keycloak评估为SSO解决方案,它在很多方面都看起来不错,但是基础知识缺乏文档。

对于领域http://localhost:8080/ test上的特定Keycloak安装,OAuth2 Authorization EndpointOAuth2 Token EndpointOpenID Connect UserInfo Endpoint是什么?

我们对使用Keycloak自己的客户端库不感兴趣,我们希望使用标准的OAuth2 / OpenID Connect客户端库,因为使用keycloak服务器的客户端应用程序将使用多种语言编写(PHP,Ruby,Node, Java,C#,Angular)。因此,使用Keycloak客户端的示例对我们没用。

8 个答案:

答案 0 :(得分:81)

对于Keycloak 1.2,可以通过网址

检索上述信息
  

http://keycloakhost:keycloakport/auth/realms/ {境界} /。众所周知/ OpenID的配置

例如,如果领域是demo,

  

http://keycloakhost:keycloakport/auth/realms/demo/.well-known/openid-configuration

以上网址的示例输出

  

{ “发行者”: “http://localhost:8080/auth/realms/demo”, “authorization_endpoint”: “http://localhost:8080/auth/realms/demo/protocol/openid-connect/auth”, “token_endpoint”: “http://localhost:8080/auth/realms/demo/protocol/openid-connect/token”, “userinfo_endpoint”:“http://localhost:8080/auth/realms/demo/protocol/openid-connect/userinfo “ ”end_session_endpoint“: ”http://localhost:8080/auth/realms/demo/protocol/openid-connect/logout“, ”jwks_uri“: ”http://localhost:8080/auth/realms/demo/protocol/openid-connect/certs“, ”grant_types_supported“:[ ”authorization_code“, ”refresh_token“, ”密码“], ”response_types_supported“:[”码 “],” subject_types_supported “:[” 公 “],” id_token_signing_alg_values_supported “:[” RS256 “],” response_modes_supported “:[” 查询“]}

https://issues.jboss.org/browse/KEYCLOAK-571

找到信息

注意:您可能需要将客户端添加到“有效重定向URI”列表

答案 1 :(得分:14)

对于1.9.3.Final版本,Keycloak提供了许多OpenID端点。这些可以在/auth/realms/{realm}/.well-known/openid-configuration找到。假设您的域名为demo,该端点将生成类似于此的JSON响应。

{
  "issuer": "http://localhost:8080/auth/realms/demo",
  "authorization_endpoint": "http://localhost:8080/auth/realms/demo/protocol/openid-connect/auth",
  "token_endpoint": "http://localhost:8080/auth/realms/demo/protocol/openid-connect/token",
  "token_introspection_endpoint": "http://localhost:8080/auth/realms/demo/protocol/openid-connect/token/introspect",
  "userinfo_endpoint": "http://localhost:8080/auth/realms/demo/protocol/openid-connect/userinfo",
  "end_session_endpoint": "http://localhost:8080/auth/realms/demo/protocol/openid-connect/logout",
  "jwks_uri": "http://localhost:8080/auth/realms/demo/protocol/openid-connect/certs",
  "grant_types_supported": [
    "authorization_code",
    "implicit",
    "refresh_token",
    "password",
    "client_credentials"
  ],
  "response_types_supported": [
    "code",
    "none",
    "id_token",
    "token",
    "id_token token",
    "code id_token",
    "code token",
    "code id_token token"
  ],
  "subject_types_supported": [
    "public"
  ],
  "id_token_signing_alg_values_supported": [
    "RS256"
  ],
  "response_modes_supported": [
    "query",
    "fragment",
    "form_post"
  ],
  "registration_endpoint": "http://localhost:8080/auth/realms/demo/clients-registrations/openid-connect"
}

据我所知,这些端点实现了Oauth 2.0规范。

答案 2 :(得分:12)

经过深入挖掘后,我们能够或多或少地获取信息(主要来自Keycloak自己的JS客户端库):

  • 授权端点: /auth/realms/{realm}/tokens/login
  • 令牌端点: /auth/realms/{realm}/tokens/access/codes

至于 OpenID Connect UserInfo ,现在(1.1.0.Final)Keycloak没有实现此端点,因此它不完全符合OpenID Connect标准。但是,已经有一个patch补充说,在撰写本文时,应该包含在1.2.x中。

- 具有讽刺意味的是,Keycloak会将id_token与访问令牌一起发回。 id_tokenaccess_token都是signed JWTs,令牌的密钥是OpenID Connect的密钥,即:

"iss":  "{realm}"
"sub":  "5bf30443-0cf7-4d31-b204-efd11a432659"
"name": "Amir Abiri"
"email: "..."

因此,虽然Keycloak 1.1.x并不完全符合OpenID Connect标准,但它确实会说"说"在OpenID Connect语言中。

答案 3 :(得分:6)

您还可以通过进入管理控制台->领域设置->单击“端点”字段上的超链接来查看此信息。

enter image description here

答案 4 :(得分:4)

Actually link to .well-know is on the first tab of your realm settings - but link doesn't look like link, but as value of text box... bad ui design. Screenshot of Realm's General Tab

答案 5 :(得分:2)

FQDN / AUTH /领域/ {realm_name} /。众所周知/ OpenID的配置

你会在这里看到所有内容,如果身份提供者也是Keycloak,那么提供这个URL将会设置其他身份提供者的一切,如果他们支持并且他们已经处理了它

答案 6 :(得分:2)

密钥斗篷版本:4.6.0

  • TokenUrl:[domain] / auth / realms / {REALM_NAME} / protocol / openid-connect / token
  • AuthUrl:[域] / auth / realms / {REALM_NAME} / protocol / openid-connect / auth

答案 7 :(得分:0)

以下链接提供了描述有关Keycloak的元数据的JSON文档

0     True
1    False
dtype: bool

/auth/realms/{realm-name}/.well-known/openid-configuration 域中使用Keycloak 6.0.1报告的以下信息

master