Skip to content

Commit

Permalink
add back some logic for doing the use_openid_identifier setting
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Lerch <[email protected]>
  • Loading branch information
ryanlerch committed Apr 5, 2024
1 parent ca1bed6 commit c8e2f1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions devel/ansible/roles/dev/files/development.ini
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ tahrir.social.twitter_user_hash = #fedora
# the fedbadges backend awarder and the tahrir frontend. Other deployments
# may set this to true with no problem.
tahrir.use_openid_email = False
tahrir.email_domain = @tinystage.test

# You can optionally create your own CSS theme for tahrir
# Specify a python module name that contains static/{css,js,img} dirs.
Expand Down
7 changes: 6 additions & 1 deletion tahrir/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@
from authlib.oauth2.rfc6750 import InvalidTokenError
from pyramid.httpexceptions import HTTPFound
from pyramid.security import remember
from pyramid.settings import asbool

if typing.TYPE_CHECKING: # pragma: no cover
import pyramid.request.Request # noqa: 401
import pyramid.response.Response # noqa: 401


def get_and_store_user(request, access_token, response):
settings = request.registry.settings
userinfo = request.registry.oidc.fedora.userinfo(token={"access_token": access_token})
if "error" in userinfo:
raise InvalidTokenError(description=userinfo["error_description"])

nickname = userinfo["nickname"]
email = userinfo["email"]
if asbool(settings.get("tahrir.use_openid_email")):
email = userinfo["email"]
else:
email = nickname + settings.get("tahrir.email_domain")

# Keep adding underscores until we get a default nickname
# that isn't already used.
Expand Down

0 comments on commit c8e2f1e

Please sign in to comment.