[gerrit_util] Add newauth.py helper

These checks will be needed in git_cl.py and probably other places.

Make it easy to change the default to opt-in as some point (and for
deletion later).

Bug: b/348024314
Change-Id: I768986e47ec2e86604268d74ca2b632458263bba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5641084
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
changes/84/5641084/7
Allen Li 10 months ago committed by LUCI CQ
parent e5490cc303
commit fa1bba51d7

@ -40,6 +40,7 @@ import auth
import gclient_utils
import metrics
import metrics_utils
import newauth
import scm
import subprocess2
@ -177,12 +178,10 @@ class Authenticator(object):
Probes the local system and its environment and identifies the
Authenticator instance to use.
"""
use_new_auth = scm.GIT.GetConfig(os.getcwd(),
'depot-tools.usenewauthstack') == '1'
use_new_auth = newauth.Enabled()
# Allow skipping SSOAuthenticator for local testing purposes.
skip_sso = scm.GIT.GetConfig(os.getcwd(),
'depot-tools.newauthskipsso') == '1'
skip_sso = newauth.SkipSSO()
authenticators: List[Type[Authenticator]]

@ -0,0 +1,20 @@
# Copyright (c) 2024 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Defines common conditions for the new auth stack migration."""
from __future__ import annotations
import os
import scm
def Enabled() -> bool:
"""Returns True if new auth stack is enabled."""
return scm.GIT.GetConfig(os.getcwd(), 'depot-tools.usenewauthstack') == '1'
def SkipSSO() -> bool:
"""Returns True if skip SSO is set."""
return scm.GIT.GetConfig(os.getcwd(), 'depot-tools.newauthskipsso') == '1'
Loading…
Cancel
Save