feat(auth): Add OAuth2 authentication

This commit is contained in:
Björn Benouarets
2026-01-27 16:35:46 +01:00
commit 50c85e9b7f
36 changed files with 1599 additions and 0 deletions

39
secnex/app/auth.py Normal file
View File

@@ -0,0 +1,39 @@
import typer
from typing import Optional
from rich.console import Console
from rich.table import Table
from rich.prompt import Prompt
from secnex.kit.auth.auth import Auth
from secnex.kit.config.config import Config
console = Console()
auth_app = typer.Typer()
@auth_app.command(name="login", help="Login to the SecNex API")
def login():
"""Login to the SecNex API"""
config = Config("default")
auth = Auth(config)
auth.login()
@auth_app.command(name="logout", help="Logout from the SecNex API")
def logout():
"""Logout from the SecNex API"""
config = Config("default")
auth = Auth(config)
auth.delete_token()
console.print(f"Logged out successfully!", style="bold green")
@auth_app.command(name="status", help="Check if user is already logged in")
def status():
"""Check if user is already logged in"""
config = Config("default")
auth = Auth(config)
token = auth.get_token()
if token is not None:
console.print(f"User is logged in!", style="bold green")
else:
console.print(f"User is not logged in!", style="bold red")