Spring引导Keycloft阻塞也未配置url



我正在学习将Keycloft作为安全系统的Spring引导。

Java 11带密钥斗篷11.0.1

我已将项目上传到https://github.com/ajeetkumarv/myemr并遵循本教程的3个链接。首先https://www.thomasvitale.com/introducing-keycloak-identity-access-management/

访问对于配置的URL/books/managers非常有效,但当我通过send.html/customer/save发送post请求时,它会显示Forbidden

我的要求是应该被允许。我需要为此配置公共用户吗?如何配置?

快速捕捉代码

@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http
.authorizeRequests()
.antMatchers("/books").hasAnyRole("Member", "Librarian")
.antMatchers("/manager").hasRole("Librarian")
.anyRequest().permitAll();
}

这里要提到两件事;

  • 顺序在HttpSecurity配置中很重要
  • 您正在调用super.config(http(

顺序很重要,这意味着如果在其他行之前有任何Request((.authenticated((,它将具有更高的优先级。并且在配置之前调用super.config((,其中anyRequest().authenticated()存在(我记得很多(。因此,通过删除super.config((行来检查您的代码(相反,在您的类中配置您需要从父类中配置的行(

最新更新