{
    "schemes": [],
    "swagger": "2.0",
    "info": {
        "description": "Authentication and session management service for Banknote Tracker",
        "title": "BNT Auth Service API",
        "contact": {},
        "version": "1.0"
    },
    "host": "localhost:9003",
    "basePath": "/",
    "paths": {
        "/auth/health": {
            "get": {
                "description": "Returns service health status",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "health"
                ],
                "summary": "Health check",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.HealthResponse"
                        }
                    }
                }
            }
        },
        "/auth/jwks": {
            "get": {
                "description": "Returns the JSON Web Key Set for token verification",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "auth"
                ],
                "summary": "Get JWKS",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.JwksResponse"
                        }
                    }
                }
            }
        },
        "/auth/login": {
            "post": {
                "description": "Authenticates a user and returns access tokens, or triggers MFA if required",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "auth"
                ],
                "summary": "User login",
                "parameters": [
                    {
                        "type": "string",
                        "description": "OTP reference for MFA verification",
                        "name": "reference",
                        "in": "query"
                    },
                    {
                        "description": "Login credentials",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/schemas.LoginRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.LoginResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/auth/logout/{session_reference}": {
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Logs out a user by invalidating the specified session",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "auth"
                ],
                "summary": "Logout session",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Session reference",
                        "name": "session_reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/auth/refresh": {
            "post": {
                "description": "Refreshes access and refresh tokens using a valid refresh token",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "auth"
                ],
                "summary": "Refresh tokens",
                "parameters": [
                    {
                        "description": "Refresh token request",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/schemas.RefreshRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.LoginResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/auth/sessions": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Returns a paginated list of sessions for the authenticated user",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "sessions"
                ],
                "summary": "List sessions",
                "parameters": [
                    {
                        "type": "integer",
                        "default": 1,
                        "description": "Page number",
                        "name": "page",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.PaginatedSessionResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/auth/sessions/{session_reference}": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Retrieves a session by its reference",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "sessions"
                ],
                "summary": "Get session details",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Session reference",
                        "name": "session_reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.SessionResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            },
            "delete": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Deletes a session by its reference",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "sessions"
                ],
                "summary": "Delete a session",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Session reference",
                        "name": "session_reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "models.LocationInfo": {
            "type": "object",
            "properties": {
                "city": {
                    "type": "string"
                },
                "country": {
                    "type": "string"
                },
                "country_code": {
                    "type": "string"
                },
                "lat": {
                    "type": "number"
                },
                "lon": {
                    "type": "number"
                },
                "region": {
                    "type": "string"
                }
            }
        },
        "schemas.AuditInfoResponse": {
            "type": "object",
            "properties": {
                "department_name": {
                    "type": "string"
                },
                "department_reference": {
                    "type": "string"
                },
                "device_name": {
                    "type": "string"
                },
                "email": {
                    "type": "string"
                },
                "full_name": {
                    "type": "string"
                },
                "ip_address": {
                    "type": "string"
                },
                "latitude": {
                    "type": "string"
                },
                "longitude": {
                    "type": "string"
                },
                "organisation_name": {
                    "type": "string"
                },
                "organisation_reference": {
                    "type": "string"
                },
                "photo_url": {
                    "type": "string"
                },
                "role": {
                    "type": "string"
                },
                "timestamp": {
                    "type": "string"
                },
                "user_reference": {
                    "type": "string"
                }
            }
        },
        "schemas.HealthResponse": {
            "type": "object",
            "properties": {
                "message": {
                    "type": "string"
                }
            }
        },
        "schemas.JwksResponse": {
            "type": "object",
            "properties": {
                "keys": {
                    "type": "array",
                    "items": {}
                }
            }
        },
        "schemas.LoginRequest": {
            "type": "object",
            "required": [
                "email",
                "password"
            ],
            "properties": {
                "device_fingerprint": {
                    "type": "string"
                },
                "device_reference": {
                    "type": "string"
                },
                "email": {
                    "type": "string"
                },
                "location": {
                    "$ref": "#/definitions/models.LocationInfo"
                },
                "password": {
                    "type": "string"
                },
                "remember_me": {
                    "type": "boolean"
                }
            }
        },
        "schemas.LoginResponse": {
            "type": "object",
            "properties": {
                "access_token": {
                    "type": "string"
                },
                "department_reference": {
                    "type": "string"
                },
                "email": {
                    "type": "string"
                },
                "expires_at_timestamp": {
                    "type": "string"
                },
                "id_token": {
                    "type": "string"
                },
                "is_onboarding_complete": {
                    "type": "boolean"
                },
                "organisation_reference": {
                    "type": "string"
                },
                "reference": {
                    "type": "string"
                },
                "refresh_token": {
                    "type": "string"
                },
                "role": {
                    "type": "string"
                },
                "session_reference": {
                    "type": "string"
                }
            }
        },
        "schemas.PaginatedSessionResponse": {
            "type": "object",
            "properties": {
                "items": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/schemas.SessionResponse"
                    }
                },
                "pagination": {
                    "$ref": "#/definitions/schemas.Pagination"
                }
            }
        },
        "schemas.Pagination": {
            "type": "object",
            "properties": {
                "has_next": {
                    "type": "boolean"
                },
                "has_previous": {
                    "type": "boolean"
                },
                "page": {
                    "type": "integer"
                },
                "pages": {
                    "type": "integer"
                },
                "size": {
                    "type": "integer"
                },
                "total": {
                    "type": "integer"
                }
            }
        },
        "schemas.ReferenceResponse": {
            "type": "object",
            "properties": {
                "reference": {
                    "type": "string"
                }
            }
        },
        "schemas.RefreshRequest": {
            "type": "object",
            "required": [
                "refresh_token"
            ],
            "properties": {
                "refresh_token": {
                    "type": "string"
                }
            }
        },
        "schemas.SessionResponse": {
            "type": "object",
            "properties": {
                "created_by": {
                    "$ref": "#/definitions/schemas.AuditInfoResponse"
                },
                "department_reference": {
                    "type": "string"
                },
                "device_reference": {
                    "type": "string"
                },
                "expires_at_timestamp": {
                    "type": "string"
                },
                "identity_reference": {
                    "type": "string"
                },
                "ip_address": {
                    "type": "string"
                },
                "is_locked": {
                    "type": "boolean"
                },
                "location": {
                    "$ref": "#/definitions/models.LocationInfo"
                },
                "organisation_reference": {
                    "type": "string"
                },
                "session_reference": {
                    "type": "string"
                },
                "updated_by": {
                    "$ref": "#/definitions/schemas.AuditInfoResponse"
                },
                "user_agent": {
                    "type": "string"
                }
            }
        },
        "shared.ApplicationError": {
            "type": "object",
            "properties": {
                "error_reference": {
                    "type": "string"
                },
                "error_type": {
                    "$ref": "#/definitions/shared.ErrorType"
                },
                "errors": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "status_code": {
                    "type": "integer"
                },
                "timestamp": {
                    "type": "string"
                }
            }
        },
        "shared.ErrorType": {
            "type": "string",
            "enum": [
                "VALIDATION_ERROR",
                "NOT_FOUND_ERROR",
                "CONFLICT_ERROR",
                "UNAUTHORIZED_ERROR",
                "FORBIDDEN_ERROR",
                "SERVER_ERROR",
                "BAD_REQUEST_ERROR",
                "CREATE_ERROR",
                "UPDATE_ERROR",
                "REDIS_ERROR",
                "MONGO_DB_ERROR",
                "INVALID_RESOURCE_ERROR",
                "RATE_LIMIT_EXCEEDED",
                "AUTHENTICATION_ERROR",
                "INVALID_CREDENTIALS",
                "TOO_MANY_REQUESTS",
                "TIMEOUT",
                "UNPROCESSABLE_ENTITY",
                "PAYMENT_ERROR"
            ],
            "x-enum-varnames": [
                "ValidationError",
                "NotFoundError",
                "ConflictError",
                "UnauthorizedError",
                "ForbiddenError",
                "ServerError",
                "BadRequestError",
                "CreateError",
                "UpdateError",
                "RedisError",
                "MongoDBError",
                "InvalidResourceError",
                "RateLimitExceeded",
                "AuthenticationError",
                "InvalidCredentialsError",
                "TooManyRequestsError",
                "TimeoutError",
                "UnprocessableEntityError",
                "PaymentError"
            ]
        }
    },
    "securityDefinitions": {
        "BearerAuth": {
            "type": "apiKey",
            "name": "Authorization",
            "in": "header"
        }
    }
}