Add explicit login/logout flows and browser selection
This commit is contained in:
@@ -4,6 +4,7 @@ import { minimatch } from "minimatch";
|
||||
|
||||
import { loadPublicConfig } from "../index.js";
|
||||
import { getGraphClient } from "../graph/auth.js";
|
||||
import { login, logout } from "../azure/index.js";
|
||||
import {
|
||||
listApps,
|
||||
listAppPermissions,
|
||||
@@ -38,6 +39,27 @@ async function runTableCommand() {
|
||||
return readJsonFromStdin();
|
||||
}
|
||||
|
||||
async function runLoginCommand(values) {
|
||||
const config = await loadPublicConfig();
|
||||
return login({
|
||||
tenantId: config.tenantId,
|
||||
clientId: config.clientId,
|
||||
resourcesCsv: values.resources,
|
||||
useDeviceCode: Boolean(values["use-device-code"]),
|
||||
noBrowser: Boolean(values["no-browser"]),
|
||||
browser: values.browser,
|
||||
});
|
||||
}
|
||||
|
||||
async function runLogoutCommand(values) {
|
||||
const config = await loadPublicConfig();
|
||||
return logout({
|
||||
tenantId: config.tenantId,
|
||||
clientId: config.clientId,
|
||||
clearAll: Boolean(values.all),
|
||||
});
|
||||
}
|
||||
|
||||
async function runListAppsCommand(values) {
|
||||
const { client } = await getGraphClientFromPublicConfig();
|
||||
let result = await listApps(client, {
|
||||
@@ -98,6 +120,10 @@ async function runListResourcePermissionsCommand(values) {
|
||||
|
||||
export async function runCommand(command, values) {
|
||||
switch (command) {
|
||||
case "login":
|
||||
return runLoginCommand(values);
|
||||
case "logout":
|
||||
return runLogoutCommand(values);
|
||||
case "table":
|
||||
return runTableCommand();
|
||||
case "list-apps":
|
||||
|
||||
Reference in New Issue
Block a user