小编adr*_*oya的帖子

使用Spring Security和Keycloak进行Spring Websockets身份验证

我正在使用Spring Boot(v1.5.10.RELEASE)为用Angular编写的应用程序创建后端.背部采用弹簧安全+钥匙扣固定.现在我正在添加一个websocket,使用STOMP而不是SockJS,并希望保护它.我正在尝试遵循Websocket令牌认证中的文档,它显示以下代码:

if (StompCommand.CONNECT.equals(accessor.getCommand())) {
  Authentication user = ... ; // access authentication header(s)
  accessor.setUser(user);
}
Run Code Online (Sandbox Code Playgroud)

我可以使用以下方法从客户端检索承载令牌:

String token = accessor.getNativeHeader("Authorization").get(0);
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何将其转换为Authentication对象?或者如何从这里开始?因为我总是得到403.这是我的websocket安全配置:

@Configuration
public class WebSocketSecurityConfig extends 
     AbstractSecurityWebSocketMessageBrokerConfigurer {

@Override
protected void configureInbound(MessageSecurityMetadataSourceRegistry 
    messages) {
messages.simpDestMatchers("/app/**").authenticated().simpSubscribeDestMatchers("/topic/**").authenticated()
    .anyMessage().denyAll();
}

  @Override
  protected boolean sameOriginDisabled() {
    return true;
  }
}
Run Code Online (Sandbox Code Playgroud)

这是Web安全配置:

@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Configuration
public class WebSecurityConfiguration extends KeycloakWebSecurityConfigurerAdapter {

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    http
        .csrf().disable()
        .authenticationProvider(keycloakAuthenticationProvider())
        .addFilterBefore(keycloakAuthenticationProcessingFilter(), BasicAuthenticationFilter.class)
        .sessionManagement()
          .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
          .sessionAuthenticationStrategy(sessionAuthenticationStrategy())
        .and()
        .authorizeRequests()
          .requestMatchers(new …
Run Code Online (Sandbox Code Playgroud)

spring spring-security websocket spring-boot keycloak

6
推荐指数
2
解决办法
5191
查看次数

使用bootstrap 3 glypicons与webjars和jsf2.2

我正在尝试在jsf 2.2中创建一个带bootstrap和glypicons的简单页面.我已经包含了webjar的bootstrap依赖项(打开jar我可以看到字体文件存在).

将应用程序部署到wildfly时,bootstrap css正常工作,但显示的图标很糟糕(如默认字体或其他东西).查看浏览器中的网络选项卡,我只看到404错误:

http://localhost:8080/proto/javax.faces.resource/bootstrap/3.1.1/fonts/glyphicons-halflings-regular.woff 404

http://localhost:8080/proto/javax.faces.resource/bootstrap/3.1.1/fonts/glyphicons-halflings-regular.ttf 404
Run Code Online (Sandbox Code Playgroud)

我尝试包含其他依赖项(bootstrap-glypicons),我只得到404错误两次.我错过了什么?

这就是我包括boostrap的方法,它适用于css:

<h:outputStylesheet library="webjars" name="bootstrap/3.1.1/css/bootstrap.min.css" />
Run Code Online (Sandbox Code Playgroud)

这就是我使用css类的方式:

<button><span class="glyphicon glyphicon-minus"></span></button>
Run Code Online (Sandbox Code Playgroud)

jsf-2.2 wildfly twitter-bootstrap-3

4
推荐指数
1
解决办法
3427
查看次数