spring-security - 使用 X509 的 SpringOauth 令牌
问题描述
我正在做一个项目,其中两种类型的客户端需要身份验证令牌。- 物联网设备 - 网络客户端
Web 客户端遵循典型套件,而 IOT 设备提供证书进行身份验证,我如何使用 AuthorizationServerConfigurerAdapter 来生成 TOKEN,除了 formlogin 路由。
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("grant_type", "password");
this.mockMvc.perform(post("/oauth/token")
.params(params)
.with(httpBasic("clientID","clientSecret"))
//.with(x509("client.crt"))
.accept("application/json;charset=UTF-8"))
.andExpect(status().isOk()).andDo(log());
什么时候
public class WebSecurity extends WebSecurityConfigurerAdapter {
//@Autowired
//private X509CustomAuthenticationProvider authenticationProvider;
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests().antMatchers("/api/**").fullyAuthenticated()
.and()
.x509()
.and()
.formLogin()
.and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and()
.csrf().disable();
// @formatter:on
}
问题是如果不是授权服务器网络安全工作正常,只要我启用
@EnableAuthorizationServer
@Configuration
public class AuthorisationServerConfiguration extends
AuthorizationServerConfigurerAdapter {
它开始投掷
{"error":"invalid_grant","error_description":"凭证错误"}
在处理令牌请求之前,我需要从证书中提取用户名密码
解决方案
推荐阅读
- xpath - IllegalArgument 异常:无法编译
- python - 根据条件分割 df 在 jupyter 中显示 nan 值
- angular - 不能在 Angular 中做 CSS 动画
- javascript - 在另一个函数内的一个函数中使用定义的 jquery 变量
- html - 播放视频时如何设置下载弹出控件的位置?
- c# - TFS REST API 获取构建失败的项目
- node.js - 无法通过 nodejs 连接到我的 ms-sql 服务器
- vba - VBA插入可以被许多用户使用的TOC
- apache-kafka - kafka分区中每条记录的记录大小是如何设置的?
- xamarin - Xamarin Android 无法重新访问共享文件