From 72ba2bb102eeb8967f4d31793983da7fa591ee37 Mon Sep 17 00:00:00 2001
From: Mohammad Torkashvand <mohammad.torkashvand@geant.org>
Date: Mon, 22 Jul 2024 11:25:02 +0200
Subject: [PATCH] remove unused code for auth

---
 gso/auth/settings.py        | 39 -------------------------------------
 gso/oss-params-example.json |  3 ---
 gso/settings.py             |  7 -------
 test/auth/test_oidc.py      |  2 +-
 test/conftest.py            |  2 +-
 5 files changed, 2 insertions(+), 51 deletions(-)
 delete mode 100644 gso/auth/settings.py

diff --git a/gso/auth/settings.py b/gso/auth/settings.py
deleted file mode 100644
index b3ab1a6a..00000000
--- a/gso/auth/settings.py
+++ /dev/null
@@ -1,39 +0,0 @@
-"""Security configurations and utilities for the GSO application. Handles OAuth2 and OpenID Connect.
-
-authentication and authorization, including token validation and user authentication. Integrates
-with external authentication providers for enhanced security management.
-
-Todo: Remove token and sensitive data from OPA console and API.
-"""
-
-from pydantic import Field
-from pydantic_settings import BaseSettings
-
-
-class Oauth2LibSettings(BaseSettings):
-    """Common settings for applications depending on oauth2."""
-
-    ENVIRONMENT: str = "local"
-    SERVICE_NAME: str = ""
-    MUTATIONS_ENABLED: bool = False
-    ENVIRONMENT_IGNORE_MUTATION_DISABLED: list[str] = Field(
-        default_factory=list, description="Environments for which to allow unauthenticated mutations"
-    )
-    OAUTH2_ACTIVE: bool = True
-    OAUTH2_AUTHORIZATION_ACTIVE: bool = True
-
-
-oauth2lib_settings = Oauth2LibSettings()
-
-
-class Oauth2Settings(BaseSettings):
-    """Configuration settings for OAuth2 and OpenID Connect (OIDC)."""
-
-    OAUTH2_RESOURCE_SERVER_ID: str = ""
-    OAUTH2_RESOURCE_SERVER_SECRET: str = ""
-    OAUTH2_TOKEN_URL: str = ""
-    OIDC_CONF_WELL_KNOWN_URL: str = ""
-    OPA_URL: str = "http://localhost:8181/v1/data/gap/gso/api/access"
-
-
-oauth2_settings = Oauth2Settings()
diff --git a/gso/oss-params-example.json b/gso/oss-params-example.json
index fb59a19b..2a402693 100644
--- a/gso/oss-params-example.json
+++ b/gso/oss-params-example.json
@@ -102,8 +102,5 @@
       "p_router": "UUID"
     },
     "scopes": ["https://graph.microsoft.com/.default"]
-  },
-    "AUTH": {
-    "opa_url": "http://127.0.0.1:8181/v1/data/gap/gso/api/access"
   }
 }
diff --git a/gso/settings.py b/gso/settings.py
index 79182702..21f517bc 100644
--- a/gso/settings.py
+++ b/gso/settings.py
@@ -171,12 +171,6 @@ class SharepointParams(BaseSettings):
     scopes: list[str]
 
 
-class AuthParams(BaseSettings):
-    """Parameters for the authentication service."""
-
-    opa_url: str
-
-
 class OSSParams(BaseSettings):
     """The set of parameters required for running :term:`GSO`."""
 
@@ -189,7 +183,6 @@ class OSSParams(BaseSettings):
     THIRD_PARTY_API_KEYS: dict[str, str]
     EMAIL: EmailParams
     SHAREPOINT: SharepointParams
-    AUTH: AuthParams
 
 
 def load_oss_params() -> OSSParams:
diff --git a/test/auth/test_oidc.py b/test/auth/test_oidc.py
index d70b544b..350d5277 100644
--- a/test/auth/test_oidc.py
+++ b/test/auth/test_oidc.py
@@ -5,6 +5,7 @@ import pytest
 from fastapi import HTTPException, Request
 from httpx import AsyncClient, NetworkError, Response
 from oauth2_lib.fastapi import OIDCConfig
+from oauth2_lib.settings import oauth2lib_settings
 
 from gso.auth.oidc import (
     OIDCAuthentication,
@@ -12,7 +13,6 @@ from gso.auth.oidc import (
     _is_callback_step_endpoint,
 )
 from gso.auth.opa import _get_decision
-from gso.auth.settings import oauth2lib_settings
 
 
 @pytest.fixture(scope="module", autouse=True)
diff --git a/test/conftest.py b/test/conftest.py
index d0391c02..d450ab43 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -11,6 +11,7 @@ from alembic import command
 from alembic.config import Config
 from faker import Faker
 from faker.providers import BaseProvider
+from oauth2_lib.settings import oauth2lib_settings
 from orchestrator import app_settings
 from orchestrator.db import (
     Database,
@@ -30,7 +31,6 @@ from sqlalchemy.engine import make_url
 from sqlalchemy.orm import scoped_session, sessionmaker
 from starlette.testclient import TestClient
 
-from gso.auth.settings import oauth2lib_settings
 from gso.db.models import PartnerType
 from gso.main import init_gso_app
 from gso.schema.partner import PartnerCreate
-- 
GitLab