Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I don't think this is a particularly the right way to go, but it's not actually very hard to make at least slightly more useful usernames out of OAuth. For my purposes, it's critical that I can at least identify the user.
Forthcoming patch is better, at least for my needs, but I think the real solution probably requires some kind of username format with tokens.
Comment | File | Size | Author |
---|---|---|---|
#8 | username-generation-1010244-8.patch | 2.97 KB | xamanu |
#7 | username-generation-1010244-7.patch | 2.99 KB | xamanu |
#7 | connector-username-1010244-7.patch | 1.74 KB | xamanu |
#1 | 1010244-name-format.patch | 1.13 KB | merlinofchaos |
#1 | 1010244-connector-username.patch | 964 bytes | merlinofchaos |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedFor this patch to work, there is also a small patch needed to connector. Attached here for convenience.
The connector patch is actually against the alpha; I hadn't noticed until just now that the -dev is actually quite a bit different. Not sure if that invalidates the patch or not.
Comment #2
voxpelli CreditAttribution: voxpelli commentedIf you know that the external usernames are unique, as they are on eg. Twitter and Digg, you can use them as the user id:s on a connector. The user id doesn't have to be a number, just something unique that tells us which local user to log in. I used that approach when testing OAuth Connector with Digg: https://gist.github.com/759648 While the result wouldn't be as beautiful as in your patch, it would at least solve the problem of recognizing which users are which.
Names aren't required for a connector as they are purely for presentation purpose - so we can't rely on them. Names also doesn't have to be unique so if eg. two John Smiths logs in from LinkedIn the usernames would conflict with your patch.
I like the idea of usernames formatted by tokens - will look into it - as you say it would probably be the best solution.
Regarding difference between alpha and dev on drupal.org - I don't see any difference?
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedI've thought a little more about this, and I realize that what I care about is the actual username; but the $username variable ends up being used for the authname as well as the username. The two absolutely do not need to be the same thing, so I think there definitely needs to be some more thought applied to this.
Comment #4
voxpelli CreditAttribution: voxpelli commentedThe two should be separated - I agree.
Comment #5
iainhallam CreditAttribution: iainhallam commentedBeginning to look at these Connector modules; I think usernames based on tokens would be a very nice way of doing things.
Comment #6
adumicic CreditAttribution: adumicic commentedHas there been any movement on this issue?
Comment #7
xamanu CreditAttribution: xamanu commentedI rerolled this patches for the newer dev branches of OAuthConntector and Connector module. I extended the patches a little bit:
* "authname" and "username" do not have to be the same anymore (username can be changed and it keeps working)
* Username gets generated based on the field specified on the OAuth Connector Provider configuration for "Name".
* If a username already exists a "_n" (with n as counting numbers) gets appended.
Comment #8
xamanu CreditAttribution: xamanu commentedRerolled patch from #7 to avoid same problem as mentioned in #1813858: Redundant argument in some _oauthconnector_fetch_field function calls.