Hi, I am evaluating the brand new 1.0.0.RELEASE without previous experience from the module. Couple of questions:
I registered Auhtorization Server as one web application and Resource Server as another one. Both are deployed to the same container. Configuration is in the bottom of this post.
1) How to force library to use only JSON? Out of box, the responses are in the format set in Accept-header. For application/json I get JSON but for application/xml I get XML (error messages, at least). The OAuth spec doesn't even define/allow XML format.
For example, requesting for oauth/token without Authorization-header I get:
When I want:Code:<oauth><error_description>An Authentication object was not found in the SecurityContext</error_description><error>unauthorized</error></oauth>
Also, if you invoke oauth/token with invalid credentials in Authorization-header from browser, I get browser asking for proper username/password. If you click cancel, the response is a HTML page.Code:{"error": "unauthorized", "error_description": "An Authentication object was not found in the SecurityContext" }
I haven't enabled the OAuth2AccessDeniedHandler.
2) Successful access token query always returns "scope" field in JSON. "scope" field is specified as "OPTIONAL, if identical to the scope requested by the client, otherwise REQUIRED". Looks like the implementation always returns scope (it's ok) but how can I configure to omit that? By specifying a custom TokenGranter?
3) How can I add extra fields to the error response? By specifying a custom TokenGranter?
4) Token endpoint (oauth/token) answers succesfully to GET, POST, DELETE and PUT. I didn't test Authroize endpoint. OAuth2 spec (v31) defines:
"The authorization server MUST support the use of the HTTP "GET" method [RFC2616] for the authorization endpoint, and MAY support the use of the "POST" method as well."
"The client MUST use the HTTP "POST" method when making access token requests."
How can I limit the endpoints to only respond to GET/POST (authorize) and just GET (token)? Do I need to deny all PUT/DELETE/(GET) via http intercept entries in XML? If so, why doesn't library automatically block the invalid
X) Core confs for refrence:
Authorization server:
Resource Server:Code:<!-- Secure Token Endpoint behind HTTP Basic --> <sec:http pattern="/oauth/token" create-session="stateless" authentication-manager-ref="clientAuthenticationManager"> <sec:intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" /> <sec:anonymous enabled="false" /> <!-- Enable HTTP Basic authentication --> <sec:http-basic /> <sec:access-denied-handler/> </sec:http> <!-- Authentication manager for Clients --> <sec:authentication-manager id="clientAuthenticationManager"> <sec:authentication-provider user-service-ref="clientDetailsUserService" /> </sec:authentication-manager> <!-- Authentication manager for Users --> <sec:authentication-manager alias="authenticationManager"> <sec:authentication-provider> <sec:user-service> <sec:user name="marissa" password="koala" authorities="ROLE_USER" /> <sec:user name="paul" password="emu" authorities="ROLE_USER" /> </sec:user-service> </sec:authentication-provider> </sec:authentication-manager> <!-- Base configuration --> <oauth:authorization-server client-details-service-ref="clientDetails" token-services-ref="tokenServices" token-endpoint-url="/oauth/token"> <oauth:authorization-code disabled="true" /> <oauth:implicit disabled="true" /> <oauth:refresh-token /> <oauth:client-credentials /> <oauth:password /> </oauth:authorization-server> <!-- Client details service --> <bean id="clientDetailsUserService" class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService"> <constructor-arg ref="clientDetails" /> </bean> <!-- Token services --> <jee:jndi-lookup id="dataSource" jndi-name="jdbc/oneidDs"/> <bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.JdbcTokenStore"> <constructor-arg ref="dataSource"/> </bean> <bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.DefaultTokenServices"> <property name="tokenStore" ref="tokenStore" /> <property name="supportRefreshToken" value="true" /> <property name="clientDetailsService" ref="clientDetails"/> </bean> <oauth:client-details-service id="clientDetails"> <oauth:client client-id="client" secret="client" authorized-grant-types="client_credentials" authorities="ROLE_USER" scope="read,write" access-token-validity="600"/> </oauth:client-details-service>
Code:<!-- Defines OAuth2 Resource Server --> <oauth:resource-server id="resourceServerFilter" resource-id="resourceServer" token-services-ref="tokenServices" /> <sec:http pattern="/**" create-session="never" entry-point-ref="oauthAuthenticationEntryPoint" use-expressions="true"> <sec:anonymous enabled="false" /> <sec:intercept-url pattern="/formula/teams/**" access="#oauth2.clientHasRole('ROLE_USER') and #oauth2.hasScope('read')" /> <sec:custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" /> <sec:expression-handler ref="oauthWebExpressionHandler" /> </sec:http> <!-- Adds WWW-Authenticate header to response suggesting location of where to authenticate --> <bean id="oauthAuthenticationEntryPoint" class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"> <property name="realmName" value="sparklr2" /> </bean> <!-- Token services --> <jee:jndi-lookup id="dataSource" jndi-name="jdbc/oneidDs"/> <bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.JdbcTokenStore"> <constructor-arg ref="dataSource"/> </bean> <bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.DefaultTokenServices"> <property name="tokenStore" ref="tokenStore" /> </bean> <!-- Dummy authentication manager. Not really needed/used for Resource Server, but required by Spring Security --> <sec:authentication-manager />


Reply With Quote
