如何在SpringSecurityOAuth-2Rest应用程序中允许特定URL中的公共(public)访问。我已保护所有以/rest/**开头的URL,但希望将/rest/about公开,因此我不需要用户进行身份验证访问它。我尝试使用permitAll()但它仍然需要请求中的token。这是我的HttpSecurity配置:@Configuration@EnableResourceServerprotectedstaticclassResourceServerConfigurationextendsResourceServerConfigurerAdapter{@Overridepu
如何在SpringSecurityOAuth-2Rest应用程序中允许特定URL中的公共(public)访问。我已保护所有以/rest/**开头的URL,但希望将/rest/about公开,因此我不需要用户进行身份验证访问它。我尝试使用permitAll()但它仍然需要请求中的token。这是我的HttpSecurity配置:@Configuration@EnableResourceServerprotectedstaticclassResourceServerConfigurationextendsResourceServerConfigurerAdapter{@Overridepu
我有SpringOAuth授权服务器,我想添加对多个客户端(id)的支持。我这样配置客户端:clients.inMemory().withClient(client).secret(clientSecret).resourceIds(resourceId).authorizedGrantTypes("client_credentials","password","refresh_token","implicit","authorization_code").authorities("ROLE_USER").scopes("read","write").autoApprove(true)
我有SpringOAuth授权服务器,我想添加对多个客户端(id)的支持。我这样配置客户端:clients.inMemory().withClient(client).secret(clientSecret).resourceIds(resourceId).authorizedGrantTypes("client_credentials","password","refresh_token","implicit","authorization_code").authorities("ROLE_USER").scopes("read","write").autoApprove(true)
在这个片段中:@RequestMapping(method=GET)publicListread(Principalprincipal){principal.getName();}principal.getName()给了我用户标识,但我需要一种方法来接收客户端凭据(客户端=>使用我的API的应用程序)。我该怎么做? 最佳答案 客户端身份可从Authentication对象获得,您可以将主体强制转换为,或直接从线程本地安全上下文中获取。类似的东西Authenticationa=SecurityContextHolder.getCon
在这个片段中:@RequestMapping(method=GET)publicListread(Principalprincipal){principal.getName();}principal.getName()给了我用户标识,但我需要一种方法来接收客户端凭据(客户端=>使用我的API的应用程序)。我该怎么做? 最佳答案 客户端身份可从Authentication对象获得,您可以将主体强制转换为,或直接从线程本地安全上下文中获取。类似的东西Authenticationa=SecurityContextHolder.getCon
首先,根据Springdoc,如果我想将用户角色映射到范围,我应该使用setCheckUserScopes(true)到DefaultOAuth2RequestFactory。因此,一种方法是注入(inject)我自己的DefaultOAuth2RequestFactorybean,正如文档所说:TheAuthorizationServerEndpointsConfigurerallowsyoutoinjectacustomOAuth2RequestFactorysoyoucanusethatfeaturetosetupafactoryifyouuse@EnableAuthorizat
首先,根据Springdoc,如果我想将用户角色映射到范围,我应该使用setCheckUserScopes(true)到DefaultOAuth2RequestFactory。因此,一种方法是注入(inject)我自己的DefaultOAuth2RequestFactorybean,正如文档所说:TheAuthorizationServerEndpointsConfigurerallowsyoutoinjectacustomOAuth2RequestFactorysoyoucanusethatfeaturetosetupafactoryifyouuse@EnableAuthorizat
我已经基于spring的sparklr示例应用程序和我在网上找到的几个示例,使用springoauth2实现了资源所有者流程。我像这样用curl测试了token请求部分,以提供客户端和用户凭据:curl-v--data"username=user1&password=user1&client_id=client1&client_secret=client1&grant_type=password"-XPOST"http://localhost:8080/samplerestspringoauth2/oauth/token"它工作正常,但是我做了以下观察:虽然根据我看到的例子,我使用了B
我已经基于spring的sparklr示例应用程序和我在网上找到的几个示例,使用springoauth2实现了资源所有者流程。我像这样用curl测试了token请求部分,以提供客户端和用户凭据:curl-v--data"username=user1&password=user1&client_id=client1&client_secret=client1&grant_type=password"-XPOST"http://localhost:8080/samplerestspringoauth2/oauth/token"它工作正常,但是我做了以下观察:虽然根据我看到的例子,我使用了B