Compare commits

..

No commits in common. "5c0d2064a4e70ba47bcfa641006bb5cf7dc6fe1e" and "3857edd6c51b83cda2de1909f3eb467287bb2482" have entirely different histories.

11 changed files with 13 additions and 49 deletions

View File

@ -18,6 +18,4 @@ data:
MONGODB_PORT: {{ .Values.authentication.configs.mongodbPort | toString | b64enc }}
METRICS_ENABLED: {{ .Values.authentication.configs.metricsEnabled | default false | toString | b64enc }}
PROBES_ENABLED: {{ .Values.authentication.configs.probesEnabled | default false | toString | b64enc }}
FREELEAPS_PRODUCT_ID: {{ .Values.authentication.configs.freeleapsProductId | b64enc | quote }}
ENVIRONMENT: {{ .Values.authentication.configs.environment | b64enc | quote }}

View File

@ -15,7 +15,7 @@ authentication:
registry: docker.io
repository: null
name: 6901bcf4ed3725f39f11343d-authentication
tag: snapshot-a2b3e4e
tag: snapshot-e6b358e
imagePullPolicy: IfNotPresent
ports:
- name: http
@ -89,8 +89,6 @@ authentication:
mongodbPort: 27017
metricsEnabled: 'false'
probesEnabled: 'true'
freeleapsProductId: 6901bcf4ed3725f39f11343d
environment: alpha
secrets:
secretStoreRef:
kind: FreeleapsSecretStore

View File

@ -18,7 +18,7 @@ authentication:
registry: docker.io
repository: null
name: 6901bcf4ed3725f39f11343d-authentication
tag: snapshot-5abb2a1
tag: snapshot-8584f90
imagePullPolicy: IfNotPresent
ports:
- name: http
@ -97,8 +97,6 @@ authentication:
mongodbPort: 27017
metricsEnabled: 'true'
probesEnabled: 'true'
freeleapsProductId: 6901bcf4ed3725f39f11343d
environment: prod
secrets:
secretStoreRef:
kind: FreeleapsSecretStore

View File

@ -82,8 +82,6 @@ authentication:
metricsEnabled: "false"
# PROBES_ENABLED
probesEnabled: "false"
freeleapsProductId: ""
environment: alpha
# AKV secrets configuration
secrets:
secretStoreRef:

View File

@ -7,7 +7,7 @@ metadata:
spec:
layout: FAST_API_VUE_3
serviceName: freeleaps-authentication
executeMode: on-demand
executeMode: fully
branch: main
components:
- name: authentication

View File

@ -25,9 +25,6 @@ ENV LOG_BASE_PATH=$CONTAINER_APP_ROOT/log/$APP_NAME
ENV BACKEND_LOG_FILE_NAME=$APP_NAME
ENV APPLICATION_ACTIVITY_LOG=$APP_NAME-activity
ENV FREELEAPS_PRODUCT_ID="6901bcf4ed3725f39f11343d"
ENV ENVIRONMENT="alpha"
WORKDIR ${CONTAINER_APP_ROOT}
COPY requirements.txt .

View File

@ -118,7 +118,7 @@ class RoleHandler:
raise RequestValidationError("Role with the provided ID already exists.")
new_doc.id = custom_role_id
await new_doc.create()
await new_doc.insert()
return new_doc
async def query_roles(self, role_key: Optional[str], role_name: Optional[str], skip: int = 0, limit: int = 10) -> \

View File

@ -36,7 +36,7 @@ class UserRoleHandler:
user_id=user_id,
role_ids=unique_role_ids
)
await user_role_doc.create()
await user_role_doc.insert()
return user_role_doc
async def get_role_and_permission_by_user_id(self, user_id: str) -> tuple[list[str], list[str]]:

View File

@ -3,7 +3,6 @@ BaseDoc - A custom document class that provides Beanie-like interface using dire
"""
import asyncio
from datetime import datetime, timezone
from bson import ObjectId
from typing import Optional, List, Dict, Any, Type, Union
from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorDatabase
from pydantic import BaseModel
@ -283,14 +282,6 @@ class BaseDoc(BaseModel, metaclass=QueryModelMeta):
# Convert Decimal objects to float for MongoDB compatibility
doc_dict = self._convert_decimals_to_float(doc_dict)
# Respect pre-populated id by mapping to MongoDB _id
id_value = getattr(self, 'id', None)
if id_value and not isinstance(id_value, QueryExpression):
try:
doc_dict['_id'] = ObjectId(id_value)
except Exception:
doc_dict['_id'] = id_value
result = await collection.insert_one(doc_dict)
# Set the id field from the inserted document
@ -323,18 +314,7 @@ class BaseDoc(BaseModel, metaclass=QueryModelMeta):
elif hasattr(self, 'auth_code'):
query['auth_code'] = self.auth_code
id_value = getattr(self, 'id', None)
if id_value and not isinstance(id_value, QueryExpression):
# Update by primary key when available
try:
object_id = ObjectId(id_value)
except Exception:
object_id = id_value
result = await collection.update_one({"_id": object_id}, {"$set": doc_dict}, upsert=True)
if result.upserted_id:
self.id = str(result.upserted_id)
elif query:
if query:
# Update existing document
result = await collection.update_one(query, {"$set": doc_dict}, upsert=True)
# If it was an insert, set the id field

View File

@ -30,9 +30,6 @@ class AppSettings(BaseSettings):
BACKEND_LOG_FILE_NAME: str = APP_NAME
APPLICATION_ACTIVITY_LOG: str = APP_NAME + "-application-activity"
FREELEAPS_PRODUCT_ID: str = ""
ENVIRONMENT: str = ""
class Config:
env_file = ".myapp.env"
env_file_encoding = "utf-8"

View File

@ -2,14 +2,12 @@ import logging
from prometheus_fastapi_instrumentator import Instrumentator
from common.config.app_settings import app_settings
def register(app):
instrumentator = Instrumentator().instrument(
app,
metric_namespace="freeleaps_{}".format(app_settings.FREELEAPS_PRODUCT_ID),
metric_subsystem=app_settings.ENVIRONMENT)
instrumentator = Instrumentator().instrument(app,
metric_namespace="freeleaps",
metric_subsystem=app_settings.APP_NAME)
@app.on_event("startup")
async def startup():
instrumentator.expose(app, endpoint="/api/_/metrics", should_gzip=True)
logging.info("Metrics endpoint exposed at /api/_/metrics")
@app.on_event("startup")
async def startup():
instrumentator.expose(app, endpoint="/api/_/metrics", should_gzip=True)
logging.info("Metrics endpoint exposed at /api/_/metrics")