Problem/Motivation
Attempting to set my site up as an authentication provider for IndieWeb
Getting a "Missing or invalid parameters to obtain code: me is empty" error
Steps to reproduce
- I setup the IndieAuth module to expose my Drupal 11 site as an authentication provider.
- Verified that my site exposes the authorization and token endpoints in the html head
- I setup all of the "rel=me" stuff and my site passes the tests on https://indiewebify.me/
- When I go to https://indielogin.com and enter my Drupal site URL it redirects me back to the authentication endpoint.
- I click the Authorize button and it redirects me back to indielogin.com with this query string
https://indielogin.com/redirect/indieauth?
state=b8a81a98f32f53a427396d57&
me=https://paullieberman.net/
&code=hflVnH7kI - Truncated
So the Drupal server is indeed sending back an authorization code, and the "me" parameter.
However when indielogin.com goes back to get the token I get.
{
"error": "invalid_request",
"error_description": "Missing or invalid parameters"
}
Checking the Drupal log it is a bit more specific.
"Missing or invalid parameters to obtain code: me is empty"
Identified the error is happening when indielogin.com makes the token request post. This post does not have a me parameter, yet the IndieAuthController insists on having one. Here is the token request post -
POST /indieauth/token HTTP/1.1 Accept: application/json Content-Length: 379
Content-Type: application/x-www-form-urlencoded
Host: paullieberman.net User-Agent: indielogin.com X-Php-Ob-Level: 1
grant_type=authorization_code
&code=cC7mvwt4Ognf4 - truncated
&client_id=https%3A%2F%2Findielogin.com%2Fid
&redirect_uri=https%3A%2F%2Findielogin.com%2Fredirect%2Findieauth
&code_verifier=6931e4e67c - truncated
I attempted in vain to hack IndieAuthController.php to make it work without the 'me' parameter, hoping to be able to send you a diff, but even when I bypassed the checks for the 'me' parameter I could not make it work. Sorry
Proposed resolution
Honestly I'm not sure what the best resolution is. The Spec appears to say that your code is correct in expecting the "me" parameter.
"6.3.2 Authorization Code Verification
The token endpoint needs to verify that the authorization code is valid, and that it was issued for the matching me, client_id and redirect_uri, and contains at least one scope."
However one would tend to believe that indielogin.com is doing the right thing.
I tried to get help on the IndieWeb Slack/Discord channel where I got a lot diagnosing the problem, but not solving it. Other people said they have their own sites working as authentication providers for indielogin.com, but none of them are using Drupal.
See also: https://indieauth.spec.indieweb.org/#authorization-request-p-11 (from #3192219: Update to latest IndieAuth spec)
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3511761-7.patch | 4.8 KB | swentel |
| #3 | 3511761-3.patch | 4.13 KB | swentel |
| #2 | 3511761-2.patch | 1.79 KB | swentel |
Issue fork indieweb-3511761
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 commentedThanks for the detailed report! I'm pretty sure I've tested this at some point in time where it probably worked, but indeed, now it doesn't. I did a quick test with https://micropublish.net/ too for instance, and nothing, so either the spec has been changed, or it's more relaxed, hard to say.
However, attached is a patch which made me able to authenticate on indielogin.com and micropublish.net. From a security point of view, it doesn't seem to be less secure not validating me, so I think it's fine.
Tests will probably fail, need to look at this (locally, they don't run anymore on the DA test infrastructure due to https://www.drupal.org/project/drupalci_environments/issues/3387737#comm...), but it would be great if you could verify the login works now.
Comment #3
swentel commentedNew patch, suble change where the 'me' optional, but, in case it's there muse validate. Fixes the tests as well.
Comment #4
lieb commentedSuccess!! Patch -2 worked. Patch -3 resulted in "Invalid State".
I agree with your logic for Patch -3, if a "me" is returned then check to see if it matches.
I will continue to engage the discussion group about what is the correct thing here:
On a token request Post
Thanks once again for your quick turn around on this.
Comment #5
swentel commentedHmm the invalid state is on indielogin.com? Haven't tested that patch yet, but I'll double check somewhere next week!
Comment #6
swentel commentedindielogin.com seems to work for me with patch 3
getting a notice though: Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\indieweb_indieauth\Entity\IndieAuthAuthorizationCode->getScopes, so will fix that while we're at it
Comment #7
swentel commentedUpdated version fixing the explode
Comment #8
swentel commentedComment #11
lieb commentedI just tested with 1.27 and it appears to be broken again. I reapplied the patch in #7 and it works again.
Comment #13
swentel commentedThis wasn't committed yet, it is now, so the next release will be fine!
Comment #15
swentel commented