我用:
Keycloak 是 Docker 中的 startet。
如果我尝试使用 Postman 将请求发送到一个简单的 REST 端点,例如:
@PreAuthorize("hasAnyRole('MONITORING_ADMIN')") //this line is irrelevant, it doesn't matter
//whether I use it or not, the issue remains
@PostMapping("/test")
fun test() {
println("test")
}
Run Code Online (Sandbox Code Playgroud)
然后我将被重定向到登录页面(有效的重定向 URI:http://localhost:8085/ *)
问题可以在 Docker 控制台的 Log 中读取:
keycloak_1 | 12:54:28,866 WARN [org.keycloak.events](默认任务 112)type=CODE_TO_TOKEN_ERROR,realmId=smight,clientId=null,userId=null,ipAddress=172.19.0.1,error=invalid_client_credentials,grant_type=authorization_code
我使用邮递员(基本
身份验证)定义授权
问题:客户端 Id=null userId=null可能是 Keycloak 没有看到 userId、clientId 或 Authorization 标头。
这是我的安全配置:
@KeycloakConfiguration
@EnableGlobalMethodSecurity(prePostEnabled = true)
class WebSecurityConfig @Autowired constructor(val basicAuthenticationProvider: BasicAuthenticationProvider) : KeycloakWebSecurityConfigurerAdapter() …Run Code Online (Sandbox Code Playgroud) 如何在javascript中对数组进行随机排序?
我已经尝试过这个:
array.sort(function(a, b){return Math.random()});
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
我想在Kotlin中改进此代码,似乎太多余了
.forEach和Lambda可以实现,但我不知道有人能帮忙吗?
val Point1 : List<Double> = topleft
.split(",")
.map {
it
.trim()
.toDouble()
}
val Point2 : List<Double> = topright
.split(",")
.map {
it
.trim()
.toDouble()
}
val Point3 : List<Double> = bottomright
.split(",")
.map {
it
.trim()
.toDouble()
}
val Point4 : List<Double> = bottomleft
.split(",")
.map {
it
.trim()
.toDouble()
}
Run Code Online (Sandbox Code Playgroud)
最后,我想拥有一个包含所有这些值的清单。topleft,topright ...是类似42.1234,54.23423
(地理坐标)的字符串
kotlin ×2
arrays ×1
javascript ×1
keycloak ×1
lambda ×1
random ×1
sorting ×1
spring ×1
spring-boot ×1