diff options
author | Mike Crute <mike@crute.us> | 2021-11-16 22:18:39 -0800 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2021-11-17 07:56:17 -0800 |
commit | 75c1a00a0915f49fa6b5a5d40b72b53e7dbecfd8 (patch) | |
tree | 8af509cec66c091115abd9541a173ac762c78529 | |
parent | e90d734c7c70513a21a7eaf78e424b2a190f2f1c (diff) | |
download | cloud-identity-broker-75c1a00a0915f49fa6b5a5d40b72b53e7dbecfd8.tar.bz2 cloud-identity-broker-75c1a00a0915f49fa6b5a5d40b72b53e7dbecfd8.tar.xz cloud-identity-broker-75c1a00a0915f49fa6b5a5d40b72b53e7dbecfd8.zip |
Allow JS access to auth token for display
-rw-r--r-- | app/middleware/auth.go | 1 | ||||
-rw-r--r-- | templates/index.tpl | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/app/middleware/auth.go b/app/middleware/auth.go index 0a20a9e..b8bf7f9 100644 --- a/app/middleware/auth.go +++ b/app/middleware/auth.go | |||
@@ -217,7 +217,6 @@ func (m *AuthenticationMiddleware) HandleCompleteLogin(c echo.Context) error { | |||
217 | Path: "/", | 217 | Path: "/", |
218 | MaxAge: int(m.CookieDuration.Seconds()), | 218 | MaxAge: int(m.CookieDuration.Seconds()), |
219 | Secure: true, | 219 | Secure: true, |
220 | HttpOnly: true, | ||
221 | SameSite: http.SameSiteStrictMode, | 220 | SameSite: http.SameSiteStrictMode, |
222 | }) | 221 | }) |
223 | 222 | ||
diff --git a/templates/index.tpl b/templates/index.tpl index cbc7a72..2a5e853 100644 --- a/templates/index.tpl +++ b/templates/index.tpl | |||
@@ -174,9 +174,13 @@ | |||
174 | return document.cookie.match(new RegExp(name + "=\"?([^;\"]*)\"?;?"))[1]; | 174 | return document.cookie.match(new RegExp(name + "=\"?([^;\"]*)\"?;?"))[1]; |
175 | } | 175 | } |
176 | 176 | ||
177 | function parseJWTExpires(token) { | ||
178 | return new Date(JSON.parse(atob(token.split(".")[1]))["exp"] * 1000); | ||
179 | } | ||
180 | |||
177 | function populateAPIKey() { | 181 | function populateAPIKey() { |
178 | document.querySelector("#api-key textarea").innerText = getCookie("session"); | 182 | document.querySelector("#api-key textarea").innerText = "Bearer " + getCookie("github-token"); |
179 | document.querySelector("#session-expires").innerText = getCookie("session-expires"); | 183 | document.querySelector("#session-expires").innerText = parseJWTExpires(getCookie("github-token")); |
180 | } | 184 | } |
181 | 185 | ||
182 | window.addEventListener('load', populateAPIKey); | 186 | window.addEventListener('load', populateAPIKey); |