我一直在使用 keycloak 1.9.1(如果有任何不同,则进行 dockerized)并且无法弄清楚如何让 TOTP 工作。我已经尝试过使用 android 的 FreeOTP 以及 Google 的身份验证器,但仍然没有运气。我可以指定keycloak使用TOTP,登录并显示二维码,用我的手机扫描它并获取OTP,但是当我输入它时总是被拒绝。目前有人有这个工作吗?
我想实现一个简单的 Spring Boot 客户端应用程序。哪个应该访问 OAauth2 安全服务。某种代理。这个“代理服务”不应该受到保护。
我想KeycloakRestTemplate用于远程 REST 调用。
按照文档:http : //www.keycloak.org/docs/latest/securing_apps/index.html#_spring_boot_adapter
到目前为止,我包含了以下依赖项:
dependencyManagement {
imports {
mavenBom "org.keycloak.bom:keycloak-adapter-bom:3.4.0-FINAL"
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.keycloak:keycloak-spring-boot-starter')
compile('org.keycloak:keycloak-spring-security-adapter')
}
Run Code Online (Sandbox Code Playgroud)
我添加了一个配置类:
@KeycloakConfiguration
public class KeycloakWebSecurityContextConfig extends
KeycloakWebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(keycloakAuthenticationProvider());
}
/**
* Defines the session authentication strategy.
*/
@Bean
@Override
protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
}
@Bean
public KeycloakConfigResolver KeycloakConfigResolver() {
return new KeycloakSpringBootConfigResolver();
}
@Autowired
public …Run Code Online (Sandbox Code Playgroud) 我尝试按照以下命令创建用户属性,但没有任何效果
/opt/keycloak/bin/kcadm.sh create users/b33088e5-321e-4b2f-afa6-7dca1871084e/user-attributes -r master -s name=user-attributes -s 'config."appid"=["APP_ID"]' -s 'config."tenantId"=["T0"]' -s 'config."ugId"=["Admin_UserGroup"]'
Run Code Online (Sandbox Code Playgroud)
错误
接下来我尝试了这个命令
/opt/keycloak/bin/kcadm.sh create components -r master -s name=user-attribute -s providerId=user-attribute -s parentId=1295a70f-25f7-4e45-bcb8-285d750 1c6d9 -s 'config."appid"=["APP_ID"]' -s 'config."tenantId"=["T0"]' -s 'config."ugId"=["Admin_UserGroup"]'
Run Code Online (Sandbox Code Playgroud)
以以下错误结束
HTTP 错误 - 400 错误请求
有谁知道在使用keycloak admin客户端(java库)创建新用户时如何设置语言环境字段。我正在使用keycloak 3.2.0.FINAL版本。
是否可以使用admin-client为所有现有用户设置此设置?
我一直在尝试使用 Keycloak Impersonation API(最近添加的)来获取另一个用户的访问令牌。我根据文档和另一个StackOverflow 问题创建了一个半成功的 CURL 请求。CURL 请求(下面)返回一个501 Not Implemented,我正在尝试解决这个问题。如果这是另一个错误,我会假设我做错了什么,但这似乎至少部分正确。
curl --verbose -X POST "http://localhost:8081/auth/realms/master/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \
-d "client_id=admin-cli" \
-d "requested_subject={TARGET_USER_ID}" \
-d "subject_token={USER_MANAGER_TOKEN}"
Run Code Online (Sandbox Code Playgroud)
到目前为止,我的工作流程是获取 Keycloak 主域“admin”用户的访问令牌(成功)并在模拟请求中使用它,以及目标用户的 Keycloak ID。我做错了什么或错过了一步吗?
我没有更改任何 Keycloak 权限,这是必需的吗?
根据我的理解和文档,目前在Keycloak v5 - Sever Installation 中默认支持和启用模拟。然而,另一篇文章(Keycloak v5 - Token Exchange)似乎表明该功能默认是禁用的;这可能是我得到的原因501 Not Implemented吗?
编辑: @qdivision 提到需要启用令牌交换才能使其工作。但是,我们正在使用jboss/keycloakDocker 映像,我想知道应该在哪里添加profile.properties文件以启用此功能?
我想使用 keycloak CLI ( kcadm.sh ) 生成一组具有一些属性(取自 Web 界面)的客户端,例如:
是否有可传递到管理 CLI 的所有属性的参考?在示例中我只能看到一些基本属性。谢谢
有没有办法使用rest admin api获取给定部分url的资源ID?
下面是我调用的端点 - http://localhost:8180/auth/realms/quickstart-serv-springboot/authz/protection/resource_set?uri=/wb/customer来获取资源 ID。
我想知道是否可以在uri的查询字符串中传递通配符,以便它返回资源ID。例如 -http://localhost:8180/auth/realms/quickstart-serv-springboot/authz/protection/resource_set?uri=/wb/customer/*或http://localhost:8180/auth/realms/quickstart-serv-springboot/authz/protection/resource_set?uri=/wb/cust*提供一个正则表达式模式来获取匹配的资源 ID。
谢谢
我希望能够读取用户上次登录事件(Keycloak)。所以我通读了 keycloak 文档,但找不到任何可以完成此操作的管理 api。到目前为止,我所做的是在 standalone-ha-xml 文件上添加一个 SPI 部分,并在 keycloak 界面上启用 Login 事件。我知道这些日志以 JSON 格式存储在名为 audit.log 的文件中。所以我不确定尝试阅读这个文件并找出用户最后一次登录是什么时候是个好主意。有什么想法吗?
<audit-logging>
<file-audit-log name="local-audit" path="audit.log" relative-to="jboss.server.log.dir" format="JSON"/>
</audit-logging>
<spi name="eventsListener">
<default-provider>jboss-logging</default-provider>
<provider name="jboss-logging" enabled="true">
<properties>
<property name="success-level" value="info"/>
<property name="error-level" value="warn"/>
</properties>
</provider>
</spi>
Run Code Online (Sandbox Code Playgroud) 我该如何解决这个错误?Python 3.7.3,Linux,keycloak==3.0.0
ImportError: cannot import name 'KeycloakOpenID' from 'keycloak' (/usr/local/lib/python3.7/dist-packages/keycloak/__init__.py)
Run Code Online (Sandbox Code Playgroud)
指令:
from keycloak import KeycloakOpenID
Run Code Online (Sandbox Code Playgroud)
但是命令import keycloak成功。我也尝试过 1.0.0、1.4、2.0.0 版本。
我正在用 Spring Security 编写一个 Spring Boot 应用程序,它有一个 REST API 和一个 Web 界面。当用户未通过身份验证时,REST API 应返回,401 Unauthorized而 Web 界面应重定向到登录页面。使用下面的配置,这在以下情况下有效:
如果请求包含授权标头但没有 bearer令牌,我无法做到的是具有相同的行为。在这种情况下,请求总是被重定向到登录页面,无论是 API 请求还是“网络”请求。到目前为止,我发现的唯一防止这种情况的选择是设置bearer-only为 true,但随后不会再将请求重定向到登录页面...
我可以尝试其他任何配置吗?谢谢!
@Configuration
@EnableWebSecurity
@ComponentScan(basePackageClasses = [KeycloakSecurityComponents::class])
open class SecurityConfiguration : KeycloakWebSecurityConfigurerAdapter() {
@Autowired
fun configureGlobal(auth: AuthenticationManagerBuilder) {
auth.authenticationProvider(keycloakAuthenticationProvider())
}
@Bean
open fun keycloakConfigResolver(): KeycloakSpringBootConfigResolver {
return KeycloakSpringBootConfigResolver()
}
@Bean
override fun sessionAuthenticationStrategy(): SessionAuthenticationStrategy {
return RegisterSessionAuthenticationStrategy(SessionRegistryImpl())
}
override fun authenticationEntryPoint(): AuthenticationEntryPoint? {
val requestMatcher = NegatedRequestMatcher(
OrRequestMatcher(
WEBAPP_ANT_PATHS.map {
AntPathRequestMatcher(it) …Run Code Online (Sandbox Code Playgroud)