diff --git a/config.py b/config.py index fd3403356..fb299620c 100644 --- a/config.py +++ b/config.py @@ -279,6 +279,10 @@ class DefaultConfig(ImmutableConfig): # Feature Flag: If set to true, autocompletion will apply to partial usernames. FEATURE_PARTIAL_USER_AUTOCOMPLETE = True + # Feature Flag: If set to true, users can confirm (and modify) their initial usernames when + # logging in via OIDC or a non-database internal auth provider. + FEATURE_USERNAME_CONFIRMATION = True + # If a namespace is defined in the public namespace list, then it will appear on *all* # user's repository list pages, regardless of whether that user is a member of the namespace. # Typically, this is used by an enterprise customer in configuring a set of "well-known" diff --git a/data/model/user.py b/data/model/user.py index 099afc9e9..836ec9c20 100644 --- a/data/model/user.py +++ b/data/model/user.py @@ -456,9 +456,12 @@ def _get_login_service(service_id): def create_federated_user(username, email, service_id, service_ident, set_password_notification, metadata={}, - email_required=True, prompts=tuple()): + email_required=True, confirm_username=True, + prompts=tuple()): prompts = set(prompts) - prompts.add(UserPromptTypes.CONFIRM_USERNAME) + + if confirm_username: + prompts.add(UserPromptTypes.CONFIRM_USERNAME) new_user = create_user_noverify(username, email, email_required=email_required, prompts=prompts) new_user.verified = True diff --git a/data/users/federated.py b/data/users/federated.py index 1ce4fcd88..15ada9b78 100644 --- a/data/users/federated.py +++ b/data/users/federated.py @@ -133,6 +133,7 @@ class FederatedUsers(object): username, set_password_notification=False, email_required=self._requires_email, + confirm_username=features.USERNAME_CONFIRMATION, prompts=prompts) except model.InvalidEmailAddressException as iae: return (None, iae.message) diff --git a/endpoints/api/user.py b/endpoints/api/user.py index de5e23850..fc68019ea 100644 --- a/endpoints/api/user.py +++ b/endpoints/api/user.py @@ -392,7 +392,8 @@ class User(ApiResource): new_username = user_data.get('username') previous_username = user.username - rename_allowed = features.USER_RENAME or confirm_username + rename_allowed = (features.USER_RENAME or + (confirm_username and features.USERNAME_CONFIRMATION)) username_changing = new_username and new_username != previous_username if rename_allowed and username_changing: diff --git a/endpoints/oauth/login.py b/endpoints/oauth/login.py index 3a0e1cc2b..642cd068b 100644 --- a/endpoints/oauth/login.py +++ b/endpoints/oauth/login.py @@ -110,6 +110,7 @@ def _conduct_oauth_login(auth_system, login_service, lid, lusername, lemail, met user_obj = model.user.create_federated_user(new_username, lemail, service_id, lid, set_password_notification=requires_password, metadata=metadata or {}, + confirm_username=features.USERNAME_CONFIRMATION, prompts=prompts, email_required=features.MAILING) diff --git a/static/directives/config/config-setup-tool.html b/static/directives/config/config-setup-tool.html index 629e3b45f..148ea14d9 100644 --- a/static/directives/config/config-setup-tool.html +++ b/static/directives/config/config-setup-tool.html @@ -1350,6 +1350,18 @@ +