我们使用Spring接受OAuth令牌生成,它接受用户名/密码/ ClientId/Secret,这非常完美。对于外部客户端,我们只需输入用户名和密码并生成OAuth令牌。没有ClientId和ClientSecret的外部客户端的Spring OAuth2令牌
<security:http pattern="/oauth/token" create-session="stateless"
authentication-manager-ref="clientAuthenticationManager"
xmlns="http://www.springframework.org/schema/security">
<security:intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
<security:anonymous enabled="false" />
<security:http-basic entry-point-ref="clientAuthenticationEntryPoint" />
<!-- include this only if you need to authenticate clients via request parameters -->
<security:custom-filter ref="clientCredentialsTokenEndpointFilter" after="BASIC_AUTH_FILTER" />
<security:access-denied-handler ref="oauthAccessDeniedHandler" />
</security:http>
下面是我们需要添加的新代码,但它是在浏览器中要求用户名和密码。
<security:http pattern="/**external**/oauth/token" create-session="stateless"
authentication-manager-ref="clientAuthenticationManager"
xmlns="http://www.springframework.org/schema/security">
<security:intercept-url pattern="/external/oauth/token" access="IS_AUTHENTICATED_FULLY" />
<security:anonymous enabled="false" />
<security:http-basic entry-point-ref="clientAuthenticationEntryPoint" />
<security:custom-filter ref="clientCredentialsTokenEndpointFilter" after="BASIC_AUTH_FILTER" />
<security:access-denied-handler ref="oauthAccessDeniedHandler" />
</security:http>
请指导我们是否可以在没有clientId的情况下生成OAuth并在内部传递clientId以生成OAuth。
同意你的观点,但我想实现的是使用内部传递的clientId生成令牌,其中用户只通过spring security xml配置传递用户名和密码。 – Rahul
您是否在谈论发布隐式令牌?通过隐式授予,Oauth客户端将把用户的浏览器重定向到服务器上的/ oauth/authorize。该URL受到保护,因此浏览器被重定向到登录页面,用户使用基于表单的身份验证进行身份验证。登录后,浏览器将显示批准页面,用户r批准/拒绝clientId标识的应用程序的访问。 OAuth客户端不应该看到凭据,只有受信任的OAuth服务器应该,否则不需要使用OAuth。 –