dlindahl / omniauth-cas

A CAS OmniAuth Strategy
MIT License
88 stars 79 forks source link

using attributes in CAS 2.0 (different namespace) #30

Closed arserbin3 closed 9 years ago

arserbin3 commented 10 years ago

From what I understand the cas:attributes was introduced in CAS 3. In CAS 2, we currently have the attributes in a different namespace like so:

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas' xmlns:xyz='http://example.com/cas'>
    <cas:authenticationSuccess>
        <cas:user>arserbin</cas:user>
        <xyz:attributes>
            <xyz:uid>arserbin</xyz:uid>
            <xyz:lastName>LastTest</xyz:lastName>
            <xyz:telephoneNumber>1235551234</xyz:telephoneNumber>
            <xyz:personAffiliation>employee</xyz:personAffiliation>
            <xyz:firstName>FirstTest</xyz:firstName>
            <xyz:displayName>FirstTest X LastTest</xyz:displayName>
        </xyz:attributes>
    </cas:authenticationSuccess>
</cas:serviceResponse>

Is it currently possible to reference these somehow, in the settings? such as:

dlindahl commented 10 years ago

@arserbin3 Do you still need this feature?

dlindahl commented 9 years ago

I added a fetch_raw_info option for #31 that may address your issue.

An example:

provider :cas,
  fetch_raw_info: lambda { |strategy, options, ticket, user_info|
    user_info['xyz:attributes'].first.inject({}) do |info, (key, value)|
        info[key.match(%r{xyz:(?<key>\w+)})[:key]] = value
        info
    end
  }

This maps the namespaced user_info attributes into non-namespaced attributes and returns them back to the strategy which will then merge them into the user info hash.