So I've spent some time looking through the cloud foundry login-server and uaa code. I'm not totally sure I am understanding your suggestion correctly. Hopefully you can shed more light.
I've modified my authorization server configuration, adding a new sec:http block:
Code:
<http request-matcher-ref="loginAuthorizeRequestMatcher" create-session="always" entry-point-ref="oauthAuthenticationEntryPoint"
authentication-manager-ref="loginAuthenticationMgr" xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />
<custom-filter ref="oauthResourceAuthenticationFilter" position="PRE_AUTH_FILTER" />
<custom-filter ref="loginAuthenticationFilter" position="FORM_LOGIN_FILTER" />
<anonymous enabled="false" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
<bean id="loginAuthorizeRequestMatcher" class="com.acme.oauth2.mvc.AcmeRequestMatcher">
<constructor-arg value="/oauth/authorize" />
<property name="accept" value="application/json" />
<property name="parameters">
<map>
<entry key="source" value="login" />
</map>
</property>
</bean>
<oauth:resource-server id="oauthResourceAuthenticationFilter" token-services-ref="tokenServices"
resource-id="oauth" entry-point-ref="oauthAuthenticationEntryPoint" />
<bean id="loginAuthenticationMgr" class="com.acme.oauth2.LoginAuthenticationManager">
<property name="userDetailsService" ref="userDetailsService"/>
</bean>
<bean id="loginAuthenticationFilter" class="com.acme.oauth2.AcmeAuthenticationFilter">
<constructor-arg ref="loginAuthenticationMgr" />
<property name="parameterNames">
<list>
<value>login</value>
<value>username</value>
<value>given_name</value>
<value>family_name</value>
<value>email</value>
</list>
</property>
</bean>
This was taken from https://github.com/cloudfoundry/uaa/...r-security.xml. Most of the implementations above are basically the same as what is in uaa.
Then I make a request to /oauth/token with grant_type=client_credentials using my trusted client credentials and get a token back.
Next I post the following to /oauth/authorize using the token I received in the previous step:
Code:
"response_type=token&source=login&username=<username>"
I expected at this point to receive a new token back for the specified user. Instead I receive an error from the AuthorizationEndpoint that a client id must be specified, which I would not expect since at this point the client is authenticated. Do I need to the client_id to the request in the authentication manager? After adding the client_id parameter to the request parameters, I get a further error that the redirect_uri must be specified. In my case I am not sure what a valid redirect_uri would be. After adding a bogus one I get this response (instead of a token):
Code:
{"username":"<username>","scope":"internal","response_type":"token","source":"login","redirect_uri":"/bogus","client_id":"internalConfigApiClient","authorizationRequest":{"scope":["internal"],"resourceIds":["oauth","internalconfigapi"],"approved":false,"authorities":[{"authority":"ROLE_CLIENT"}],"authorizationParameters":{"username":"<username>","response_type":"token","scope":"internal","source":"login","redirect_uri":"/bogus","client_id":"internalConfigApiClient"},"approvalParameters":{},"state":null,"clientId":"internalConfigApiClient","responseTypes":["token"],"redirectUri":"/bogus","denied":true}}
Any guidance or clarification would be really appreciated.