Last active
February 12, 2020 12:47
-
-
Save janherich/3e4e036098db241b7671bfa441df707c to your computer and use it in GitHub Desktop.
syslogin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(: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