Skip to content

Commit

Permalink
CORE-1311: updated the CAS OAuth handling to work when single-value a…
Browse files Browse the repository at this point in the history
…ttributes are returned as individual strings or arrays of strings
  • Loading branch information
slr71 committed Mar 1, 2021
1 parent 4e82ef7 commit 78cde45
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/terrain/util/oauth.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

(defn user-from-oauth-profile
[{{:keys [id attributes]} :oauth-profile}]
{:shortUsername id
:username (str id "@" (config/uid-domain))
:email (first (:email attributes))
:firstName (first (:firstName attributes))
:lastName (first (:lastName attributes))
:commonName (first (:name attributes))})
(let [get-attr (fn [k] (let [v (get attributes k)] (if (sequential? v) (first v) v)))]
{:shortUsername id
:username (str id "@" (config/uid-domain))
:email (get-attr :email)
:firstName (get-attr :firstName)
:lastName (get-attr :lastName)
:commonName (get-attr :name)}))

(def ^:private required-fields [[:attributes :email] [:id]])

Expand Down

0 comments on commit 78cde45

Please sign in to comment.