Accessing headers from Scripted attribute (Shibboleth 3.x)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing headers from Scripted attribute (Shibboleth 3.x)

Ilya Rumyantsev
Hi all, I would like to access http headers from attributes. So far the following works (for jsp pages):

`request.getHeader("X-MY-HEADER");`


How can I access a header from the attribute, e.g.:

```
<AttributeDefinition
      id="headerValue"
      xsi:type="ScriptedAttribute">
    <Script><![CDATA[
      # Something like this
      headerValue = request.headers["X-MY-HEADER"]
    }
    ]]></Script>
  </AttributeDefinition>

```

Thanks a lot,
Ilya
--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Accessing headers from Scripted attribute (Shibboleth 3.x)

Rod Widdowson
Inject the request context as per [1]

Note that it might not always be there (for non browser profiles, for which you should look at the profile request context..)

[1] https://wiki.shibboleth.net/confluence/display/IDP30/ScriptedAttributeDefinition#ScriptedAttributeDefinition-Accessingotherinformation

Sent from my iPad

On 19 Dec 2019, at 12:22, Ilya Rumyantsev <[hidden email]> wrote:

Hi all, I would like to access http headers from attributes. So far the following works (for jsp pages):

`request.getHeader("X-MY-HEADER");`


How can I access a header from the attribute, e.g.:

```
<AttributeDefinition
     id="headerValue"
     xsi:type="ScriptedAttribute">
   <Script><![CDATA[
     # Something like this
     headerValue = request.headers["X-MY-HEADER"]
   }
   ]]></Script>
 </AttributeDefinition>

```

Thanks a lot,
Ilya
--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]

--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Aw: Re: Accessing headers from Scripted attribute (Shibboleth 3.x)

Ilya Rumyantsev
Thanks Rod, works like charm


> Gesendet: Donnerstag, 19. Dezember 2019 um 13:49 Uhr
> Von: "Rod Widdowson" <[hidden email]>
> An: "Shib Users" <[hidden email]>
> Betreff: Re: Accessing headers from Scripted attribute (Shibboleth 3.x)
>
> Inject the request context as per [1]
>
> Note that it might not always be there (for non browser profiles, for which you should look at the profile request context..)
>
> [1] https://wiki.shibboleth.net/confluence/display/IDP30/ScriptedAttributeDefinition#ScriptedAttributeDefinition-Accessingotherinformation
>
> Sent from my iPad
>
> > On 19 Dec 2019, at 12:22, Ilya Rumyantsev <[hidden email]> wrote:
> >
> > Hi all, I would like to access http headers from attributes. So far the following works (for jsp pages):
> >
> > `request.getHeader("X-MY-HEADER");`
> >
> >
> > How can I access a header from the attribute, e.g.:
> >
> > ```
> > <AttributeDefinition
> >      id="headerValue"
> >      xsi:type="ScriptedAttribute">
> >    <Script><![CDATA[
> >      # Something like this
> >      headerValue = request.headers["X-MY-HEADER"]
> >    }
> >    ]]></Script>
> >  </AttributeDefinition>
> >
> > ```
> >
> > Thanks a lot,
> > Ilya
> > --
> > For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
> > To unsubscribe from this list send an email to [hidden email]
> --
> For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
> To unsubscribe from this list send an email to [hidden email]
--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Accessing headers from Scripted attribute (Shibboleth 3.x)

Peter Schober
* Ilya Rumyantsev <[hidden email]> [2019-12-19 14:15]:
> Thanks Rod, works like charm

Could you share the result for posterity, either here or in the wiki
as an example?

-peter
--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Accessing headers from Scripted attribute (Shibboleth 3.x)

Cantor, Scott E.
On 12/19/19, 8:22 AM, "users on behalf of Peter Schober" <[hidden email] on behalf of [hidden email]> wrote:

> Could you share the result for posterity, either here or in the wiki as an example?

All of the components in the system that have a customObjectRef or (in Spring XML) p:customObject-ref capability can access any of it by pointing to shibboleth.HttpServletRequest and using the custom (or $custom) variable that will be defined.

-- Scott


--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Aw: Re: Accessing headers from Scripted attribute (Shibboleth 3.x)

Ilya Rumyantsev
> Could you share the result for posterity, either here or in the wiki as an example?

Here we go, please feel free to post it in Wiki:

 <AttributeDefinition
      id="attrFromHeader"
      xsi:type="ScriptedAttribute"
      customObjectRef="shibboleth.HttpServletRequest">
    <Script><![CDATA[
       header = custom.getHeader("X-MY-HEADER");
       attrFromHeader.addValue(header.toString());
    ]]></Script>
  </AttributeDefinition>

BR, Ilya

> Gesendet: Donnerstag, 19. Dezember 2019 um 14:29 Uhr
> Von: "Cantor, Scott" <[hidden email]>
> An: "Shib Users" <[hidden email]>
> Betreff: Re: Accessing headers from Scripted attribute (Shibboleth 3.x)
>
> On 12/19/19, 8:22 AM, "users on behalf of Peter Schober" <[hidden email] on behalf of [hidden email]> wrote:
>
> > Could you share the result for posterity, either here or in the wiki as an example?
>
> All of the components in the system that have a customObjectRef or (in Spring XML) p:customObject-ref capability can access any of it by pointing to shibboleth.HttpServletRequest and using the custom (or $custom) variable that will be defined.
>
> -- Scott
>
>
> --
> For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
> To unsubscribe from this list send an email to [hidden email]
>
--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]