hansamann
Apr 4th, 2011, 09:26 AM
Hi,
I've setup a basic provider using monstly in memory services. This is all based on the configuration I got from tonr for oauth2 - and I am using the M3 version of spring oauth.
I think I got issues mapping the token urls.. also there are a couple of client auth elements I cannot answer right now:
- consumer key -> this is oauth:client clientId, right? so in below config "my-trusted-client-with-secret" for example
- consumer secret -> somesecret in the example below
- Authorization Method: GET or POST? I chose POST - is there a way to see this from the config below what a client should use here? Is there a predefined callback url parameter that needs to be used? Or can this be configured?
- Authorization URL: I thought this would be authorization-url="/oauth/authorize", just as defined in the oauth:provider - but somehow this does not work. When the client redirects the user to the url , I get thsi response:
{
error: "invalid_request"
error_description: "A verification code must be supplied."
}
To my understanding, a verification code must be supplied to the access token request...
-Access Token Type: I can choose Header and Query Parameter here... what is used rigth now, based on below config? How can I see that?
-Access Token URL: I am lost at this point. All I found was a way to configure the authorization URL. Any defaults here?
Below is the config! Thanx for your replies!
Sven
<http auto-config='true' access-denied-page="/login.jsp">
<intercept-url pattern="/rest/**" access="ROLE_USER" />
<intercept-url pattern="/request_token_authorized.jsp"
access="ROLE_USER" />
<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<form-login authentication-failure-url="/login.jsp"
default-target-url="/index.jsp" login-page="/login.jsp"
login-processing-url="/login.do" />
<logout logout-success-url="/index.jsp" logout-url="/logout.do" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="xxx" password="xx" authorities="ROLE_USER, ROLE_ADMIN" />
<user name="xx" password="xx" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<beans:bean id="tokenServices"
class="org.springframework.security.oauth2.provider.token .InMemoryOAuth2ProviderTokenServices">
<beans:property name="supportRefreshToken" value="true" />
</beans:bean>
<oauth:provider client-details-service-ref="clientDetails"
token-services-ref="tokenServices" authorization-url="/oauth/authorize"><!-- authorization url is default -->
<oauth:verification-code user-approval-page="/oauth/confirm_access" />
</oauth:provider>
<oauth:client-details-service id="clientDetails">
<oauth:client clientId="my-trusted-client"
authorizedGrantTypes="password,authorization_code,refresh_token" />
<oauth:client clientId="my-trusted-client-with-secret"
authorizedGrantTypes="password,authorization_code,refresh_token"
secret="somesecret" />
<oauth:client clientId="my-less-trusted-client"
authorizedGrantTypes="authorization_code" />
<oauth:client clientId="tonr" authorizedGrantTypes="authorization_code" />
</oauth:client-details-service>
I've setup a basic provider using monstly in memory services. This is all based on the configuration I got from tonr for oauth2 - and I am using the M3 version of spring oauth.
I think I got issues mapping the token urls.. also there are a couple of client auth elements I cannot answer right now:
- consumer key -> this is oauth:client clientId, right? so in below config "my-trusted-client-with-secret" for example
- consumer secret -> somesecret in the example below
- Authorization Method: GET or POST? I chose POST - is there a way to see this from the config below what a client should use here? Is there a predefined callback url parameter that needs to be used? Or can this be configured?
- Authorization URL: I thought this would be authorization-url="/oauth/authorize", just as defined in the oauth:provider - but somehow this does not work. When the client redirects the user to the url , I get thsi response:
{
error: "invalid_request"
error_description: "A verification code must be supplied."
}
To my understanding, a verification code must be supplied to the access token request...
-Access Token Type: I can choose Header and Query Parameter here... what is used rigth now, based on below config? How can I see that?
-Access Token URL: I am lost at this point. All I found was a way to configure the authorization URL. Any defaults here?
Below is the config! Thanx for your replies!
Sven
<http auto-config='true' access-denied-page="/login.jsp">
<intercept-url pattern="/rest/**" access="ROLE_USER" />
<intercept-url pattern="/request_token_authorized.jsp"
access="ROLE_USER" />
<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<form-login authentication-failure-url="/login.jsp"
default-target-url="/index.jsp" login-page="/login.jsp"
login-processing-url="/login.do" />
<logout logout-success-url="/index.jsp" logout-url="/logout.do" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="xxx" password="xx" authorities="ROLE_USER, ROLE_ADMIN" />
<user name="xx" password="xx" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<beans:bean id="tokenServices"
class="org.springframework.security.oauth2.provider.token .InMemoryOAuth2ProviderTokenServices">
<beans:property name="supportRefreshToken" value="true" />
</beans:bean>
<oauth:provider client-details-service-ref="clientDetails"
token-services-ref="tokenServices" authorization-url="/oauth/authorize"><!-- authorization url is default -->
<oauth:verification-code user-approval-page="/oauth/confirm_access" />
</oauth:provider>
<oauth:client-details-service id="clientDetails">
<oauth:client clientId="my-trusted-client"
authorizedGrantTypes="password,authorization_code,refresh_token" />
<oauth:client clientId="my-trusted-client-with-secret"
authorizedGrantTypes="password,authorization_code,refresh_token"
secret="somesecret" />
<oauth:client clientId="my-less-trusted-client"
authorizedGrantTypes="authorization_code" />
<oauth:client clientId="tonr" authorizedGrantTypes="authorization_code" />
</oauth:client-details-service>