[JIRA] (IDP-1907) Enable Spring MVC's CORS-handling features

Henri Mikkonen (Jira) jira at shibboleth.atlassian.net
Wed Feb 23 16:35:43 UTC 2022


Henri Mikkonen ( https://shibboleth.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A1614c4a5-c89e-4edc-9421-990bd6ea85fd ) *commented* on IDP-1907 ( https://shibboleth.atlassian.net/browse/IDP-1907?atlOrigin=eyJpIjoiODM4NWVmMWZmZTM4NGZhZmEyZjRjZWNlNjBjOTU0ZTMiLCJwIjoiaiJ9 )

Re: Enable Spring MVC's CORS-handling features ( https://shibboleth.atlassian.net/browse/IDP-1907?atlOrigin=eyJpIjoiODM4NWVmMWZmZTM4NGZhZmEyZjRjZWNlNjBjOTU0ZTMiLCJwIjoiaiJ9 )

The following snippet activates the Spring CORS-handling with default settings ( CorsConfiguration.applyPermitDefaultValues() ) to the OIDC OP’s userinfo endpoint

   <bean id="corsConfiguration" class="org.springframework.web.cors.CorsConfiguration"/>

   <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
       <property name="targetObject" ref="corsConfiguration" />
       <property name="targetMethod" value="applyPermitDefaultValues" />
   </bean>

   <bean id="corsSource" class="org.springframework.web.cors.UrlBasedCorsConfigurationSource"/>

   <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
       <property name="targetObject" ref="corsSource" />
       <property name="targetMethod" value="registerCorsConfiguration" />
       <property name="arguments">
           <list>
               <bean class="java.lang.String" c:original="/oidc/userinfo"/>
               <ref bean="corsConfiguration"/>
           </list>
       </property>
   </bean>

   <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping" p:order="0"
           p:flowRegistry-ref="flowRegistry">
       <property name="flowUrlHandler">
           <bean class="net.shibboleth.idp.profile.support.PathInfoSupportingFlowUrlHandler"
               p:supportedFlows="#{getObject('shibboleth.RESTFlows') ?: getObject('shibboleth.DefaultRESTFlows')}" />
       </property>
       <property name="corsConfigurationSource">
           <ref bean="corsSource"/>
       </property>
   </bean>

curl pre-flight example after the setup above:

curl -H "Origin: http://localhost" -H "Access-Control-Request-Method: GET" -X OPTIONS --verbose https://server.local/idp/profile/oidc/userinfo  
...
> OPTIONS /idp/profile/oidc/userinfo HTTP/1.1
> Host: server.local
> User-Agent: curl/7.64.1
> Accept: */*
> Origin: http://localhost
> Access-Control-Request-Method: GET
> 
< HTTP/1.1 200 OK
< Date: Wed, 23 Feb 2022 16:33:08 GMT
...
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,HEAD,POST
< Access-Control-Max-Age: 1800
< Allow: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
< Content-Length: 0
< Set-Cookie: JSESSIONID=node0m41pazehxk5gxxvhzpso3i1r4.node0;Path=/idp;Secure;HttpOnly
< Access-Control-Allow-Origin: *

( https://shibboleth.atlassian.net/browse/IDP-1907#add-comment?atlOrigin=eyJpIjoiODM4NWVmMWZmZTM4NGZhZmEyZjRjZWNlNjBjOTU0ZTMiLCJwIjoiaiJ9 ) Add Comment ( https://shibboleth.atlassian.net/browse/IDP-1907#add-comment?atlOrigin=eyJpIjoiODM4NWVmMWZmZTM4NGZhZmEyZjRjZWNlNjBjOTU0ZTMiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100192- sha1:731e729 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/commits/attachments/20220223/e9d7a33e/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-avatar-fdb10c4d-0a32-48d7-9c92-b8396986b123
Type: image/png
Size: 341 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20220223/e9d7a33e/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-comment-icon-ddd16114-d79c-477d-92d4-fec18988728b
Type: image/png
Size: 1084 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20220223/e9d7a33e/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-footer-desktop-logo-b9804ba3-82ee-444e-86f1-655e6932a5eb
Type: image/png
Size: 10805 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20220223/e9d7a33e/attachment-0005.png>


More information about the commits mailing list