Announcement Announcement Module
Collapse
No announcement yet.
Problem with curly brackets in state parameter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with curly brackets in state parameter

    Hi,

    I am working on the open source ORCID project, which uses Spring Security Oauth to provide OAuth2 to client applications.

    A client application is using the 'state' parameter in the authorization code flow, as recommended in the OAuth2 specification.

    They are putting a JSON style string into the state parameter. Here is the string before URL encoding.

    state={"source":"account","j_id":"10","p_id":"8537 0","form_type":"get_orcid"}

    However, this seems to cause an exception when the user confirms authorization.

    Here's how it looks using curl.

    curl -i -b 'JSESSIONID=8D51E8E6BBCBE3872FBBBE1794BD866D' 'http://devsandbox.orcid.org/oauth/authorize?response_type=code&redirect_uri=http%3A% 2F%2Flocalhost:8989%2Fjopmts%2Forcid%2Finfo&client _id=0000-0003-4222-0282&scope=%2Forcid-profile%2Fread-protected&state=%7B%22source%22%3A%22account%22%2C %22j_id%22%3A%2210%22%2C%22p_id%22%3A%2285370%22%2 C%22form_type%22%3A%22get_orcid%22%7D'

    curl -i -L -b 'JSESSIONID=AD574FEBDE53BDA2339BDD54B53A8F44' --data "user_oauth_approval=true" 'http://devsandbox.orcid.org/oauth/authorize'

    HTTP/1.1 500 Internal Server Error
    Server: Apache-Coyote/1.1
    Content-Type: text/html;charset=utf-8
    Transfer-Encoding: chunked
    Vary: Accept-Encoding
    Date: Fri, 01 Jun 2012 14:38:41 GMT
    Connection: close

    <html>...

    org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is java.lang.IllegalArgumentException: Model has no value for '&quot;source&quot;:&quot;account&quot;,&quot;j_id &quot;:&quot;10&quot;,&quot;p_id&quot;:&quot;85370 &quot;,&quot;form_type&quot;:&quot;get_orcid&quot; '
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:894)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 311)
    org.orcid.frontend.web.filters.TermsAndConditionsA cceptanceCheckFilter.doFilterInternal(TermsAndCond itionsAcceptanceCheckFilter.java:41)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.access.intercept. FilterSecurityInterceptor.invoke(FilterSecurityInt erceptor.java:116)
    org.springframework.security.web.access.intercept. FilterSecurityInterceptor.doFilter(FilterSecurityI nterceptor.java:83)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.access.ExceptionT ranslationFilter.doFilter(ExceptionTranslationFilt er.java:113)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.session.SessionMa nagementFilter.doFilter(SessionManagementFilter.ja va:101)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.authentication.An onymousAuthenticationFilter.doFilter(AnonymousAuth enticationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.servletapi.Securi tyContextHolderAwareRequestFilter.doFilter(Securit yContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.savedrequest.Requ estCacheAwareFilter.doFilter(RequestCacheAwareFilt er.java:45)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.authentication.Ab stractAuthenticationProcessingFilter.doFilter(Abst ractAuthenticationProcessingFilter.java:182)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.authentication.lo gout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.context.SecurityC ontextPersistenceFilter.doFilter(SecurityContextPe rsistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.session.Concurren tSessionFilter.doFilter(ConcurrentSessionFilter.ja va:125)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    org.springframework.security.web.FilterChainProxy. doFilter(FilterChainProxy.java:173)
    org.springframework.web.filter.DelegatingFilterPro xy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterPro xy.doFilter(DelegatingFilterProxy.java:259)
    org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter.doFilterInternal(OpenEntityManager InViewFilter.java:147)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)

    ...</html>

    It looks like RedirectView is trying to interpret the curly brackets as a placeholder to be replaced.

    I suspect this could be fixed in AuthorizationEndpoint.java by setting the following on the RedirectView object.

    redirectView.setExpandUriTemplateVariables(false);

    Any thoughts?

    Best regards,

    Will

  • #2
    The client is supposed to verify that the state is the same as it sent in in the original authorization request. I have my doubts that it can do that if it doesn't store some state itself, and then the usual approach of sending an opaque key, not a JSON object, would work better. So I would question why your client is doing that.

    However, I also don't immediately see why the expand template flag can't be set to false as we don't put any templates in there intentionally in the AuthorizationEndpoint. I'm slightly hesitant as well though because that flag is really useful when you need it and I don't want to close off that option for ever. I suppose we could give the state parameter some special treatment, since it is just a passthru, and that might be preferable (e.g. actually require a template to be used and populate its value with the state supplied by the client). Any offers?

    Comment

    Working...
    X