Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ from an example config file which lists all available options::

# Use SREG nickname as authname (default false)
#use_nickname_as_authname = false

# Use SREG email as authname (default false) -- overrides
# use_nickname_as_authname if both are set to true.
#use_email_as_authname = false

# If you want username to be written as
# "username_in_remote_system <openid_url>" use:
Expand Down
30 changes: 18 additions & 12 deletions authopenid/authopenid.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def trac_auth_cookie_lifetime(self):
use_nickname_as_authname = BoolOption('openid', 'use_nickname_as_authname', False,
""" Whether the nickname as retrieved by SReg is used as username""")

use_email_as_authname = BoolOption('openid', 'use_email_as_authname', False,
""" Whether the email-address as retrieved by SReg is used as username. When enabled, this option overrides the use_nickname_as_authname option.""")

trust_authname = BoolOption('openid', 'trust_authname', False,
"""WARNING: Only enable this if you know what this mean!
This could make identity theft very easy if you do not control the OpenID provider!
Expand Down Expand Up @@ -716,6 +719,8 @@ def _do_process(self, req):
# New identity URL -> create new authname/user.
if self.check_list and self.check_list_username:
authname = cl_username
elif self.use_email_as_authname and email:
authname = email
elif self.use_nickname_as_authname and nickname:
authname = nickname
elif session_attr.get('name'):
Expand Down Expand Up @@ -751,18 +756,19 @@ def authnames(base):
if (no_session_exists and no_permissions_defined):
# name is free :-)
break
# Set attributes for new user on the
# current anonymous session. It will be promoted to
# the new authenticated session on the next request
# (by Session.__init__).
#
# NB: avoid dict.update here to ensure that
# DetachedSession.__getitem__ gets a chance to
# normalize values
for name, value in session_attr.items():
req.session[name] = value
self.env.log.info("Created new user '%s' for "
"OpenID identifier %s", authname, info.identity_url)

# Set attributes for new user on the
# current anonymous session. It will be promoted to
# the new authenticated session on the next request
# (by Session.__init__).
#
# NB: avoid dict.update here to ensure that
# DetachedSession.__getitem__ gets a chance to
# normalize values
for name, value in session_attr.items():
req.session[name] = value
self.env.log.info("Created new user '%s' for "
"OpenID identifier %s", authname, info.identity_url)

req.authname = authname

Expand Down