@wtfalch/auth 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.js +21 -10
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -175,11 +175,21 @@ export function createAuth(input) {
|
|
|
175
175
|
/**
|
|
176
176
|
* Where a sign-out lands: the issuer's own logout, so its session ends and
|
|
177
177
|
* the next sign-in asks who again, rather than straight back to
|
|
178
|
-
* `afterLogout`. What this function can see fail -- no
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
178
|
+
* `afterLogout`. What this function can see fail -- no `end_session_endpoint`
|
|
179
|
+
* published, the issuer not answering -- falls back to the plain redirect a
|
|
180
|
+
* sign-out has always ended with. Losing the issuer's co-operation is never
|
|
181
|
+
* a reason to fail somebody's sign-out.
|
|
182
|
+
*
|
|
183
|
+
* Having no id token is the one failure that does not fall back, because the
|
|
184
|
+
* plain redirect leaves the issuer's session standing and the next sign-in is
|
|
185
|
+
* silent. `end_session` cannot rescue it either: without a hint the issuer
|
|
186
|
+
* takes its v1 branch and ends v1 user-agent sessions, of which a v2 sign-in
|
|
187
|
+
* has none. Routing a hint-less `end_session` to the hosted login instead
|
|
188
|
+
* needs the instance's `loginV2.required`, which overrides every app's own
|
|
189
|
+
* `loginVersion.loginV2.baseUri` with the instance's -- and each app here
|
|
190
|
+
* hosts its own sign-in at `/auth`, so that flag is not available to us.
|
|
191
|
+
* The hosted login's `/logout` sits at the issuer's origin, where
|
|
192
|
+
* `scripts/provision.mjs` points the instance's `loginV2.baseUri`.
|
|
183
193
|
*
|
|
184
194
|
* `afterLogout` not being a registered `post_logout_redirect_uri` is a
|
|
185
195
|
* failure this function cannot see: that request reaches the issuer, which
|
|
@@ -191,11 +201,12 @@ export function createAuth(input) {
|
|
|
191
201
|
*/
|
|
192
202
|
const endIssuerSession = async (idToken, cookies) => {
|
|
193
203
|
const afterLogout = new URL(options().afterLogout, options().appUrl).href;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
204
|
+
if (!idToken) {
|
|
205
|
+
return redirect(new URL('/logout', options().issuer).href, cookies, 303);
|
|
206
|
+
}
|
|
207
|
+
const target = await oidc()
|
|
208
|
+
.endSessionUrl(idToken, afterLogout)
|
|
209
|
+
.catch(() => null);
|
|
199
210
|
return redirect(target?.href ?? afterLogout, cookies, 303);
|
|
200
211
|
};
|
|
201
212
|
const logout = async (request) => {
|
package/package.json
CHANGED