forked from contextforge-org/contextforge-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhoami.py
More file actions
49 lines (41 loc) · 1.84 KB
/
Copy pathwhoami.py
File metadata and controls
49 lines (41 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
"""Location: ./cforge/commands/settings/whoami.py
Copyright 2025
SPDX-License-Identifier: Apache-2.0
Authors: Gabe Goodhart
CLI command: whoami
"""
# Local
from cforge.common.console import get_console
from cforge.common.http import get_token_file, load_token
from cforge.config import get_settings
from cforge.profile_utils import get_active_profile
def whoami() -> None:
"""Show current authentication status and token source.
Displays where the authentication token is coming from (if any) and
information about the active profile if one is set.
"""
console = get_console()
settings = get_settings()
env_token = settings.mcpgateway_bearer_token
stored_token = load_token()
active_profile = get_active_profile()
# Display active profile information
console.print("[bold cyan]Active Profile:[/bold cyan]")
console.print(f" [cyan]Name:[/cyan] {active_profile.name}")
console.print(f" [cyan]ID:[/cyan] {active_profile.id}")
console.print(f" [cyan]Email:[/cyan] {active_profile.email}")
console.print(f" [cyan]API URL:[/cyan] {active_profile.api_url}")
if active_profile.metadata and active_profile.metadata.environment:
console.print(f" [cyan]Environment:[/cyan] {active_profile.metadata.environment}")
console.print()
# Display authentication status
if env_token:
console.print("[green]✓ Authenticated via MCPGATEWAY_BEARER_TOKEN environment variable[/green]")
console.print(f"[cyan]Token:[/cyan] {env_token[:10]}...")
elif stored_token:
token_file = get_token_file()
console.print(f"[green]✓ Authenticated via stored token in {token_file}[/green]")
console.print(f"[cyan]Token:[/cyan] {stored_token[:10]}...")
else:
console.print("[yellow]Not authenticated. Run 'cforge login' to authenticate.[/yellow]")