This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-25 at 14:00 UTC+2 (a few minutes of down time)

Commit 78131ca6 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

User: flag to prefer access tokens in VCS operations

This is necessary for 2FA and SSO, but we don't want to make
it the general case because:

- accessing `User.token` does not guarantee that the token is
  initialized. It probably will at some point, be it only for
  uniformity with `webdriver`, which does
- creating a token if needed is expensive, and may not be useful
  for some temporary users.
parent 4f0262c58912
......@@ -229,7 +229,8 @@ class Project(object):
heptapod = self.heptapod
if pwd is None:
pwd = self.heptapod.get_user(user_name).password
user = self.heptapod.get_user(user_name)
pwd = user.token if user.vcs_token_only else user.password
url = heptapod.parsed_url
return "{scheme}://{auth}@{netloc}/{path}".format(
......@@ -27,6 +27,14 @@ class User(object):
email = attr.ib(default=None, repr=False)
password = attr.ib(default=None, repr=False)
token = attr.ib(default=None, repr=False)
vcs_token_only = attr.ib(default=False, repr=False)
"""Are VCS HTTP operations to be made only with the access token?
If two-factor authentication is activated, or if the user can only log
through SSO, only private tokens can enable VCS HTTP push and pull.
_webdriver = attr.ib(default=None, repr=False)
_python_gitlab_client = attr.ib(default=None, repr=False)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment