mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-05 02:40:55 -07:00
Add enforcedAuthType setting (#6564)
This commit is contained in:
@@ -8,6 +8,7 @@ import type { Config } from '@google/gemini-cli-core';
|
||||
import { AuthType } from '@google/gemini-cli-core';
|
||||
import { USER_SETTINGS_PATH } from './config/settings.js';
|
||||
import { validateAuthMethod } from './config/auth.js';
|
||||
import { type LoadedSettings } from './config/settings.js';
|
||||
|
||||
function getAuthTypeFromEnv(): AuthType | undefined {
|
||||
if (process.env['GOOGLE_GENAI_USE_GCA'] === 'true') {
|
||||
@@ -26,8 +27,21 @@ export async function validateNonInteractiveAuth(
|
||||
configuredAuthType: AuthType | undefined,
|
||||
useExternalAuth: boolean | undefined,
|
||||
nonInteractiveConfig: Config,
|
||||
settings: LoadedSettings,
|
||||
) {
|
||||
const effectiveAuthType = configuredAuthType || getAuthTypeFromEnv();
|
||||
const enforcedType = settings.merged.security?.auth?.enforcedType;
|
||||
if (enforcedType) {
|
||||
const currentAuthType = getAuthTypeFromEnv();
|
||||
if (currentAuthType !== enforcedType) {
|
||||
console.error(
|
||||
`The configured auth type is ${enforcedType}, but the current auth type is ${currentAuthType}. Please re-authenticate with the correct type.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const effectiveAuthType =
|
||||
enforcedType || getAuthTypeFromEnv() || configuredAuthType;
|
||||
|
||||
if (!effectiveAuthType) {
|
||||
console.error(
|
||||
|
||||
Reference in New Issue
Block a user