简体   繁体   English

春季安全oauth2 client_credentials仅流

[英]spring security oauth2 client_credentials flow only

I'm trying to use spring boot to create an oauth2 authorization that only supports the client credentials flow. 我正在尝试使用Spring Boot创建仅支持客户端凭据流的oauth2授权。 As I understand that flow, the client accesses the /oauth/token endpoint directly. 据我了解,该流程是客户端直接访问/ oauth / token端点。 Is there a way to disable the /oauth/authorize endpoint in spring boot and allow direct access to /oauth/token without having to be fully authorized first? 有没有一种方法可以在春季启动时禁用/ oauth / authorize端点并允许直接访问/ oauth / token,而无需先获得完全授权?

@Configuration
@EnableAuthorizationServer
public class OAuth2Configuration extends AuthorizationServerConfigurerAdapter {

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        // TODO: Is there something I can do here to disable /oauth/authorize?
        endpoints.authenticationManager(authenticationManager);
    }

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        // client details configuration
    }

}

I can't speak to disabling the authorize endpoint but you're right that you can go directly to the token endpoint with the client credentials flow. 我不能说禁用授权端点,但您是对的,您可以使用客户端凭据流直接转到令牌端点。 I'm probably restating something you already know but the credentials for a "client" (client_id/client_secret) are different from the credentials of a "user" (username/password). 我可能正在重申您已经知道的一些信息,但是“客户端”的凭据(client_id / client_secret)与“用户”的凭据(用户名/密码)不同。 A "user" goes to the authorize endpoint so that the client can then get tokens from the token endpoint. “用户”进入授权端点,以便客户端随后可以从令牌端点获取令牌。 A "client" (in the client credentials flow) provides the client credentials to the token endpoint directly. “客户端”(在客户端凭证流中)直接将客户端凭证提供给令牌端点。 Do you need to disable the authorize endpoint? 您需要禁用授权端点吗?

So, for client_credentials flow, you don't need to go to authorize first (you don't need to disable it). 因此,对于client_credentials流程,您无需先进行授权(无需禁用它)。 Here's how you'd curl your token if your spring-boot authorization server was on localhost:8080: 如果您的spring-boot授权服务器位于localhost:8080上,则可以使用以下方法卷曲令牌:

curl -H "Authorization: Basic d2VhcHA6" -X POST http://localhost:8080/oauth/token?grant_type=client_credentials curl -H“授权:基本d2VhcHA6” -X POST http:// localhost:8080 / oauth / token?grant_type = client_credentials

where d2VhcHA6 is the base64 encoding of your "client_id:client_secret" 其中d2VhcHA6是“ client_id:client_secret”的base64编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot 2 Spring-Security 5 OAuth2 支持 client_credentials grant_type - Spring Boot 2 Spring-Security 5 OAuth2 support for client_credentials grant_type Spring OAuth2 client_credentials与预先认证的用户结合使用 - Spring OAuth2 client_credentials in combination with preauthenticated user Spring Oauth2 客户端凭据流示例 - Spring Oauth2 client credentials flow example 为什么 Spring Boot WebClient OAuth2 (client_credentials) 要求为每个请求提供一个新令牌? - Why Spring Boot WebClient OAuth2 (client_credentials) asks for a new token for each request? OAuth2客户端凭据通过Spring Boot Keycloak集成进行流动 - OAuth2 client credentials flow via Spring Boot Keycloak integration spring oauth2 客户端凭据流中的令牌交换 - Token exchange in spring oauth2 client credentials flow 如何在 Spring Boot Oauth2 授权服务器中 grant_type=client_credentials 时抛出错误凭据的任何异常 - How to throw any Exceptions for wrong credentials when grant_type=client_credentials in Spring Boot Oauth2 Authorization Server Java Spring Security OAuth2:通过POST接受客户端凭据 - Java Spring Security OAuth2: Accept client credentials via POST Spring OAuth2安全性-客户端凭据-自定义AuthenticationProvider - Spring OAuth2 Security - Client Credentials - Custom AuthenticationProvider 了解OAuth2客户端凭据流 - Understanding OAuth2 Client credentials flow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM