Skip to content

Instantly share code, notes, and snippets.

@janherich
Last active February 12, 2020 12:47
Show Gist options
  • Save janherich/3e4e036098db241b7671bfa441df707c to your computer and use it in GitHub Desktop.
Save janherich/3e4e036098db241b7671bfa441df707c to your computer and use it in GitHub Desktop.
syslogin
(:require [net.cgrand.enlive-html :as enlive]
[vurderings-api.rest.assertion :as assertion]
[vurderings-api.rest.shared :as shared])
(defn syslogin-assertion->tokens
"Takes XML response from non-interactive ADFS login, returns map with `:access-token`, `:refresh-token` and `:access-token-exp` keys"
[syslogin-response-xml jwt-sign-secret response-ip]
(let [xml-nodes (enlive/xml-resource (java.io.StringReader. syslogin-response-xml))
assertion-str (apply str (enlive/emit* (first (enlive/select xml-nodes [:Assertion]))))
assertion (assertion/parse-saml-assertion (shared/stream->obj assertion-str))]
(create-tokens auth/standard-issuer
(auth-claims assertion {:ipAddress response-ip})
jwt-sign-secret)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment