Skip to content

Commit

Permalink
Switch popup redirect from 302 to script.
Browse files Browse the repository at this point in the history
The client needs to receive the URL fragment from OIDC,
but Safari does not preserve it on 302 redirects:
https://bugs.webkit.org/show_bug.cgi?id=158420
  • Loading branch information
RubenVerborgh committed Oct 18, 2018
1 parent 4f3a008 commit 7344830
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/api/authn/webid-oidc.js
Expand Up @@ -90,14 +90,12 @@ function middleware (oidc) {

// Static assets related to authentication
const authAssets = [
['/.well-known/solid/login/', '../static/popup-redirect.html', false],
['/common/', 'solid-auth-client/dist-popup/popup.html'],
['/common/js/', 'solid-auth-client/dist-lib/solid-auth-client.bundle.js'],
['/common/js/', 'solid-auth-client/dist-lib/solid-auth-client.bundle.js.map']
]
authAssets.map(([path, file]) => routeResolvedFile(router, path, file))
// Redirect for .well-known login popup location
router.get('/.well-known/solid/login',
(req, res) => res.redirect('/common/popup.html'))
authAssets.map(args => routeResolvedFile(router, ...args))

// Initialize the OIDC Identity Provider routes/api
// router.get('/.well-known/openid-configuration', discover.bind(provider))
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js
Expand Up @@ -234,8 +234,8 @@ function reqToPath (req) {
/**
* Adds a route that serves a static file from another Node module
*/
function routeResolvedFile (router, path, file) {
const fullPath = path + file.match(/[^/]+$/)
function routeResolvedFile (router, path, file, appendFileName = true) {
const fullPath = appendFileName ? path + file.match(/[^/]+$/) : path
const fullFile = require.resolve(file)
router.get(fullPath, (req, res) => res.sendFile(fullFile))
}
1 change: 1 addition & 0 deletions static/popup-redirect.html
@@ -0,0 +1 @@
<script>location.replace(`/common/popup.html${location.hash}`)</script>

0 comments on commit 7344830

Please sign in to comment.