Keycloak 如何使用SpringCloudGateway和KeyClove验证curl(或Postman,或Ajax)调用

Keycloak 如何使用SpringCloudGateway和KeyClove验证curl(或Postman,或Ajax)调用,keycloak,spring-cloud-gateway,Keycloak,Spring Cloud Gateway,我使用的是带KeyClose的SpringCloudGateway,身份验证可以从浏览器中进行。 但是,没有带有令牌的Authorization头,而是SESSIONcookie。 我根本不想使用cookies,而是token 目前,如果我发布到http://localhost:8080/auth/realms/myrealm/protocol/openid-连接/token以获取令牌,并尝试将access\u token放入Authorization头中,使用Bearer它不起作用,但返回登录

我使用的是带KeyClose的SpringCloudGateway,身份验证可以从浏览器中进行。 但是,没有带有令牌的
Authorization
头,而是
SESSION
cookie。 我根本不想使用cookies,而是token

目前,如果我发布到
http://localhost:8080/auth/realms/myrealm/protocol/openid-连接/token
以获取令牌,并尝试将
access\u token
放入
Authorization
头中,使用
Bearer
它不起作用,但返回登录页面

另外,如果我将
keydape.js
添加到浏览器页面,并在成功登录后尝试添加
xhttp.setRequestHeader('Authorization'、'bearrier'+keydape.token)
对于Ajax调用,它再次返回登录页面

那么,如何从任何提供了有效令牌的客户机上使用带KeyClose的SpringCloudGateway呢

这是我的网关配置,它后面带有
/web/
路由的web应用程序没有应用任何安全性。KeyClope配置了基本的公共客户端

    @Bean
    public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http,
            ReactiveClientRegistrationRepository clientRegistrationRepository) {
        http.oauth2Login();
        http.logout(logout -> logout
                .logoutSuccessHandler(new OidcClientInitiatedServerLogoutSuccessHandler(clientRegistrationRepository)));
        http.authorizeExchange().pathMatchers("/web/private").authenticated()
                .pathMatchers("/web/**").permitAll()
                .anyExchange().authenticated();
        http.headers().frameOptions().mode(Mode.SAMEORIGIN);
        http.csrf().disable();
        return http.build();
    }

如果要使用访问令牌向Spring网关发出请求,则需要将其设置为资源服务器: