{authmap}.authname is unique and does not allows for multiple external account.

Saying I want to have my drupal account linked with my LinkedIn Account, and Facebook Account. My LinkedIn id is q-mqwh5qzJ, my Facebook id is 9847382945, in this case I will have two rows in my authmap:

aid uid authname module
1 1 q-mqwh5qzJ linkedin
2 1 9847382945 facebook

In this case the unique key is not a problem, but we are not sure about the unicity between facebook and linkedin, and even worst for other external providers.

It then would make sense to put the key (authname, module) unique.

Otherwise there is no point using the authmap table, we can use dedicated table facebook_authmap that the module should implement, with the fields: aid, uid, authname. Then the unique key on authname make sense, moreover, we can scale the column size to fit facebook id (in this case an int), for improved performances. (ie. for linkedin char(10) ).

Related issue: #817118: Remove {authmap} and migrate OpenID entries to their own table

Comments

Dave Cohen’s picture

I'm with you, as I suggested in http://drupal.org/node/817118#comment-3050884

In modules/fb, I currently use the authmap table as you describe, where the authname is just a number. I'm told this is wrong, and it should be something like "9847382945@facebook", in order to remain unique to my module.

So, I'm in the process of changing modules/fb to use its own table, which will map uid to facebook ids more efficiently, and make both columns ints instead of a string. In the near future, modules/fb will not use the authmap table at all.

The authmap api in drupal is lame; unnecessarily complex, and apparently designed with only openid in mind. AFAIK, it gets no better in D7.

Sylvain Lecoy’s picture

I think the way to go is letting modules define their own table for external authentication, and lookup this table hooking a user_external_load().

Any external provider have to define a table with:

uid authname

Having OpenID as best practises and developer guide but not to lock people into this VARCHAR(128) for authname.

Damien Tournoud’s picture

Status: Active » Closed (duplicate)

In that scheme, it is the job of the modules to namespace the authname. A common convention is id@module.

The research to change this for Drupal 8 is done in #817118: Remove {authmap} and migrate OpenID entries to their own table.