This one is as tricky as #3236329: Authorize session getting overridden to reproduce, but there are a couple of ways, of which the first one is the easiest:
Important: automatic authorization must be enabled to reproduce the 'access denied' screen.
- Arrive at the login screen, go back immediately
- Open a different tab, and login on the authorize server
- Go back to other tab, hit open id connect: at this point you will be redirected and be presented with an access denied screen, because the state query parameter is the same as the first request, while the second attempt generated a new one.
It's kind of an edge case, but we also have this when a user needs to register first. In our case, email validation isn't required immediately, so you are authenticated as soon as you register. Users then go back to the original site, hit login again, but then end up with the access denied screen. We are trying to guide them with messages to redirect them to oauth/authorize, but you know, not everyone reads messages :)
The fix is relatively easy:
if ($this->currentUser()->isAnonymous()) {
// This part stays the same
}
else {
// A user may be authenticated at this point (e.g. registration flow ..)
if ($bridgeRequest->get('client_id')) {
$_SESSION['oauth2_server_authorize'] = $bridgeRequest;
}
}
Issue fork oauth2_server-3471891
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
swentel commentedComment #3
swentel commentedComment #5
swentel commentedThinking about it some more the next day,
This means though that $_SESSION will always contain the 'oauth2_server_authorize' which might not be necessary at all. But that would also be the case in my original proposal, so maybe that one could be changed a bit like this:
Feedback welcome of course :)
Comment #6
swentel commentedChanging title as it makes more sense I think