-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filters/auth: add login redirect stub support #3028
Conversation
Signed-off-by: Alexander Yastrebov <[email protected]>
4bf22a9
to
387cbf3
Compare
387cbf3
to
221cd0e
Compare
For single page applications user may want to return javascript stub that stores location hash into localstorage and then redirects user to the authorization url. Signed-off-by: Alexander Yastrebov <[email protected]>
221cd0e
to
377a4c8
Compare
`) | ||
-> oauthGrant() | ||
-> "http://localhost:9090"; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and now this inside a yaml :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its fine actually:
routes:
- pathSubtree: /
filters:
- |
annotate("oauthGrant.loginRedirectStub", `
<!doctype html>
<html lang="en">
<head>
<title>Redirecting...</title>
<script>
if (window.location.hash !== null) {
localStorage.setItem('original-location-hash', window.location.hash);
}
window.location.replace('{{authCodeURL}}');
</script>
</head>
</html>
`)
- oauthGrant()
- |
inlineContent(`
<!doctype html>
<html lang="en">
<head>
<title>Hello world</title>
</head>
<body>
<p id="hello">Hello world</p>
<script>
const hash = localStorage.getItem('original-location-hash');
if (hash !== null) {
window.location.hash = hash;
localStorage.removeItem('original-location-hash');
}
document.getElementById('hello').innerText = 'Page: ' + window.location.hash;
</script>
</body>
</html>
`)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
👍 |
Wow, thanks for implementing this so quickly 🚀 |
👍 |
[Changes](zalando/skipper@v0.21.54...v0.21.61) * [build(deps): bump amazonlinux from `ef9435f` to `5478f82` in /fuzz](zalando/skipper#3031) * [build(deps): bump actions/upload-artifact from 4.3.1 to 4.3.2](zalando/skipper#3033) * [build(deps): bump actions/checkout from 4.1.2 to 4.1.3](zalando/skipper#3032) * [build(deps): bump github.com/miekg/dns from 1.1.58 to 1.1.59](zalando/skipper#3030) * [proxy: support configurable metrics](zalando/skipper#3027) * [filters/auth: add login redirect stub support](zalando/skipper#3028) * [filters: move annotate into own package](zalando/skipper#3023) * [filters/auth: add jwtMetrics](zalando/skipper#3020) * [filters/builtin: add annotate filter](zalando/skipper#3022) Signed-off-by: Alexander Yastrebov <[email protected]>
[Changes](zalando/skipper@v0.21.54...v0.21.61) * `build(deps): bump amazonlinux from `ef9435f` to `5478f82` in /fuzz` zalando/skipper#3031 * `build(deps): bump actions/upload-artifact from 4.3.1 to 4.3.2` zalando/skipper#3033 * `build(deps): bump actions/checkout from 4.1.2 to 4.1.3` zalando/skipper#3032 * `build(deps): bump github.com/miekg/dns from 1.1.58 to 1.1.59` zalando/skipper#3030 * `proxy: support configurable metrics` zalando/skipper#3027 * `filters/auth: add login redirect stub support` zalando/skipper#3028 * `filters: move annotate into own package` zalando/skipper#3023 * `filters/auth: add jwtMetrics` zalando/skipper#3020 * `filters/builtin: add annotate filter` zalando/skipper#3022 Signed-off-by: Alexander Yastrebov <[email protected]>
[Changes](zalando/skipper@v0.21.54...v0.21.61) * zalando/skipper#3031 * zalando/skipper#3033 * zalando/skipper#3032 * zalando/skipper#3030 * zalando/skipper#3027 * zalando/skipper#3028 * zalando/skipper#3023 * zalando/skipper#3020 * zalando/skipper#3022 Signed-off-by: Alexander Yastrebov <[email protected]>
[Changes](zalando/skipper@v0.21.54...v0.21.62) * zalando/skipper#3025 * zalando/skipper#3031 * zalando/skipper#3033 * zalando/skipper#3032 * zalando/skipper#3030 * zalando/skipper#3027 * zalando/skipper#3028 * zalando/skipper#3023 * zalando/skipper#3020 * zalando/skipper#3022 Signed-off-by: Alexander Yastrebov <[email protected]>
Login redirect stub introduced by #3028 uses `{{authCodeURL}}` placeholder that is a valid mustache template and hence inconvenient to use from mustache templates. This change adds a second `{authCodeURL}` placeholder. Signed-off-by: Alexander Yastrebov <[email protected]>
Login redirect stub introduced by #3028 uses `{{authCodeURL}}` placeholder that is a valid mustache template and hence inconvenient to use from mustache templates. This change adds a second `{authCodeURL}` placeholder and `X-Auth-Code-Url` response header. Signed-off-by: Alexander Yastrebov <[email protected]>
Login redirect stub introduced by #3028 uses `{{authCodeURL}}` placeholder that is a valid mustache template and hence inconvenient to use from mustache templates. This change adds a second `{authCodeURL}` placeholder and `X-Auth-Code-Url` response header. Signed-off-by: Alexander Yastrebov <[email protected]>
For single page applications user may want to return javascript stub that stores location hash into localstorage and then redirects user to the authorization url.