java - 发布具有基本身份验证的用户
问题描述
我正在使用 OAuth2 和 JWT 身份验证来访问我的 Spring Boot 应用程序的资源。我不想限制新用户的发布,但我想添加基本身份验证以及我的客户端应用程序可以发送的用户和密码。我尝试使用httpBasic()
并添加域名,但在 Postman 中我仍然可以不受限制地发布用户。
这是我的资源服务器:
@Configuration
@EnableResourceServer
public class ResourceServer extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers(HttpMethod.GET, "api/users").permitAll()
.antMatchers(HttpMethod.GET,"/api/users/{id}","/api/rols" ).hasRole("ADMIN")
.antMatchers(HttpMethod.POST,"/api/users" ).permitAll()
// .and()
//.httpBasic()
// .realmName("My realm");
}
}
解决方案
推荐阅读
- javascript - 如何在html中为音频标签赋予标题
- api - 适用于 Google Kubernetes Engine (GKE) 的 REST API
- oracle - 如何在 PowerDesigner 中实现没有外键的物理数据模型
- c++ - 2 个期货之间的依赖关系
- html - Understanding Css Grouping
- php - WooCommerce checkout stuck on loading
- python - 我应该在 Python 中大写常量吗?
- mysql - SQL where 查询到 IN 条件的第一行
- javascript - 当单选按钮选择为否时禁用需要消息
- mysql - Mysql 组复制:永远卡在 RECOVERING 上