From bf5ecb15c774243960fc14c48f28cfb15262852a Mon Sep 17 00:00:00 2001 From: Torstein Lundervold Nesheim Date: Tue, 7 Mar 2023 14:58:24 +0100 Subject: [PATCH] Remove 'OPENAPI_CLIENT_ID' This is not needed, we can simply log into our backend instead --- src/isar/apis/api.py | 13 ++++++------- src/isar/apis/security/authentication.py | 2 -- src/isar/config/settings.py | 3 --- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/isar/apis/api.py b/src/isar/apis/api.py index 521857b7..50c83333 100644 --- a/src/isar/apis/api.py +++ b/src/isar/apis/api.py @@ -1,22 +1,21 @@ import logging +import os from http import HTTPStatus from logging import Logger -import os from typing import List, Union import click import uvicorn -from fastapi import FastAPI, Security, Request +from fastapi import FastAPI, Request, Security from fastapi.middleware.cors import CORSMiddleware from fastapi.routing import APIRouter from injector import inject -from pydantic import AnyHttpUrl - from opencensus.ext.azure.trace_exporter import AzureExporter +from opencensus.trace.attributes_helper import COMMON_ATTRIBUTES from opencensus.trace.samplers import ProbabilitySampler -from opencensus.trace.tracer import Tracer from opencensus.trace.span import SpanKind -from opencensus.trace.attributes_helper import COMMON_ATTRIBUTES +from opencensus.trace.tracer import Tracer +from pydantic import AnyHttpUrl from isar.apis.models.models import ControlMissionResponse, StartMissionResponse from isar.apis.schedule.scheduling_controller import SchedulingController @@ -76,7 +75,7 @@ def _create_app(self) -> FastAPI: swagger_ui_oauth2_redirect_url="/oauth2-redirect", swagger_ui_init_oauth={ "usePkceWithAuthorizationCodeGrant": True, - "clientId": self.authenticator.openapi_client_id, + "clientId": settings.AZURE_CLIENT_ID, }, ) diff --git a/src/isar/apis/security/authentication.py b/src/isar/apis/security/authentication.py index cce1d7c8..994435d3 100644 --- a/src/isar/apis/security/authentication.py +++ b/src/isar/apis/security/authentication.py @@ -43,11 +43,9 @@ async def validate_has_role(user: User = Depends(azure_scheme)) -> None: class Authenticator: def __init__( self, - openapi_client_id: str = settings.OPENAPI_CLIENT_ID, authentication_enabled: bool = settings.AUTHENTICATION_ENABLED, ) -> None: self.logger = logging.getLogger("api") - self.openapi_client_id: str = openapi_client_id self.authentication_enabled: bool = authentication_enabled enabled_string = "enabled" if self.authentication_enabled else "disabled" self.logger.info(f"API authentication is {enabled_string}") diff --git a/src/isar/config/settings.py b/src/isar/config/settings.py index e9d4c144..7f74ee30 100644 --- a/src/isar/config/settings.py +++ b/src/isar/config/settings.py @@ -111,9 +111,6 @@ class Settings(BaseSettings): print("Using environment variable for AZURE_CLIENT_ID") AZURE_CLIENT_ID = os.environ[azure_client_id_name] - # Client ID for the OpenAPI client - OPENAPI_CLIENT_ID: str = Field(default="5f412c20-8c36-4c69-898f-d2b5051f5fb6") - # MQTT username # The username and password is set by the MQTT broker and must be known in advance # The password should be set as an environment variable "MQTT_PASSWORD"