Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
AE-1906: Use suomifi logout flow with virtu
Browse files Browse the repository at this point in the history
  • Loading branch information
solita-tonipu authored Jun 8, 2023
1 parent 6f07101 commit d8cc30f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
4 changes: 1 addition & 3 deletions etp-backend/src/main/clj/solita/etp/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@
;; Logout
(def keycloak-suomifi-logout-url (env "KEYCLOAK_SUOMIFI_LOGOUT_URL" index-url))
(def keycloak-virtu-logout-url (env "KEYCLOAK_VIRTU_LOGOUT_URL" index-url))
(def cognito-logout-url (env "COGNITO_LOGOUT_URL" (str index-url "?client=id=localhost")))
(def cognito-suomifi-logout-url (env "COGNITO_SUOMIFI_LOGOUT_URL" (str index-url "/uloskirjauduttu")))
(def cognito-virtu-logout-url (env "COGNITO_VIRTU_LOGOUT_URL" (str index-url "/uloskirjauduttu")))
(def cognito-logout-url (env "COGNITO_LOGOUT_URL" (str index-url "/uloskirjauduttu")))

;; Laskutus
(def laskutus-sftp-host (env "LASKUTUS_SFTP_HOST" "localhost"))
Expand Down
21 changes: 8 additions & 13 deletions etp-backend/src/main/clj/solita/etp/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,14 @@

(defn logout-location [req]
(let [{:keys [data]} (req->jwt req)]
(if data
(if-let [id-token (:custom:id_token data)] ; TODO: Remove check when new keycloak version is in use
(if (:custom:VIRTU_localID data)
(str config/cognito-virtu-logout-url
"&logout_uri=" config/keycloak-virtu-logout-url)
(str config/keycloak-suomifi-logout-url
"?id_token_hint=" id-token
"&post_logout_redirect_uri=" (URLEncoder/encode config/cognito-suomifi-logout-url StandardCharsets/UTF_8)))
(str config/cognito-logout-url
"&logout_uri="
(str (if (:custom:VIRTU_localID data)
config/keycloak-virtu-logout-url
config/keycloak-suomifi-logout-url))))
(if-let [id-token (:custom:id_token data)]
(if (:custom:VIRTU_localID data)
(str config/keycloak-virtu-logout-url
"?id_token_hint=" id-token
"&post_logout_redirect_uri=" (URLEncoder/encode config/cognito-logout-url StandardCharsets/UTF_8))
(str config/keycloak-suomifi-logout-url
"?id_token_hint=" id-token
"&post_logout_redirect_uri=" (URLEncoder/encode config/cognito-logout-url StandardCharsets/UTF_8)))
(str config/index-url "/uloskirjauduttu"))))

(def empty-cookie {:value ""
Expand Down

0 comments on commit d8cc30f

Please sign in to comment.