{
    "openapi": "3.0.2",
    "servers": [
        {
            "url": "https://login-stage.schmalz.com"
        }
    ],
    "info": {
        "title": "login.schmalz.com",
        "version": "1.0.0",
        "description": "Schmalz Login Service"
    },
    "components": {
        "parameters": {},
        "headers": {},
        "schemas": {
            "CreateCrmUserMessage": {
                "type": "object",
                "description": "Event message for asynchronous creation of a a user in the CRM. Received via EventBridge.",
                "required": ["email"],
                "properties": {
                    "email": {
                        "type": "string",
                        "format": "email"
                    }
                },
                "additionalProperties": false
            },
            "CreatePasswordlessUserMessage": {
                "type": "object",
                "description": "Event message for asynchronous creation of a user without password. Received via EventBridge.",
                "required": [
                    "email",
                    "salutation",
                    "firstName",
                    "lastName",
                    "locale",
                    "country",
                    "street",
                    "zip",
                    "company",
                    "phone"
                ],
                "properties": {
                    "email": {
                        "type": "string",
                        "format": "email"
                    },
                    "salutation": {
                        "type": "string"
                    },
                    "firstName": {
                        "type": "string",
                        "maxLength": 50
                    },
                    "lastName": {
                        "type": "string",
                        "maxLength": 50
                    },
                    "locale": {
                        "type": "string"
                    },
                    "currency": {
                        "type": "string",
                        "description": "ISO 4217 currency code (e.g. EUR, USD)"
                    },
                    "country": {
                        "type": "string",
                        "description": "ISO 3166-1 alpha-2 country code (e.g. DE, US)"
                    },
                    "phone": {
                        "type": "string",
                        "format": "phone"
                    },
                    "academicDegree": {
                        "type": "string"
                    },
                    "jobTitle": {
                        "type": "string",
                        "maxLength": 75
                    },
                    "department": {
                        "type": "string",
                        "maxLength": 255
                    },
                    "externalId": {
                        "type": "string"
                    },
                    "industry": {
                        "type": "string"
                    },
                    "company": {
                        "type": "string"
                    },
                    "street": {
                        "type": "string"
                    },
                    "zip": {
                        "type": "string"
                    },
                    "city": {
                        "type": "string"
                    },
                    "region": {
                        "type": "string"
                    }
                },
                "additionalProperties": false
            },
            "IdTokenPayload": {
                "type": "object",
                "required": ["id_token"],
                "properties": {
                    "id_token": {
                        "type": "string"
                    }
                },
                "additionalProperties": false
            },
            "PasswordPolicy": {
                "type": "object",
                "properties": {
                    "MinimumLength": {
                        "type": "integer"
                    },
                    "RequireLowercase": {
                        "type": "boolean"
                    },
                    "RequireNumbers": {
                        "type": "boolean"
                    },
                    "RequireSymbols": {
                        "type": "boolean"
                    },
                    "RequireUppercase": {
                        "type": "boolean"
                    },
                    "TemporaryPasswordValidityDays": {
                        "type": "integer"
                    }
                }
            },
            "UserDetails": {
                "type": "object",
                "required": ["salutation", "firstName", "lastName", "phone", "email"],
                "properties": {
                    "salutation": {
                        "type": "string"
                    },
                    "firstName": {
                        "type": "string"
                    },
                    "lastName": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string"
                    },
                    "phone": {
                        "type": "string"
                    },
                    "academicDegree": {
                        "type": "string"
                    },
                    "jobTitle": {
                        "type": "string"
                    },
                    "department": {
                        "type": "string"
                    }
                },
                "additionalProperties": false
            },
            "UserDetailsResponse": {
                "type": "object",
                "required": ["attributes", "idToken"],
                "properties": {
                    "attributes": {
                        "$ref": "#/components/schemas/UserDetails"
                    },
                    "idToken": {
                        "type": "string"
                    }
                },
                "additionalProperties": false
            },
            "UrlResponse": {
                "type": "object",
                "required": ["url"],
                "properties": {
                    "url": {
                        "type": "string"
                    }
                },
                "additionalProperties": false
            },
            "UpdateLocalePayload": {
                "type": "object",
                "required": ["email", "locale"],
                "properties": {
                    "email": {
                        "type": "string"
                    },
                    "locale": {
                        "type": "string"
                    }
                },
                "additionalProperties": false
            }
        },
        "x-amazon-apigateway-integrations": {
            "sessionHandler": {
                "payloadFormatVersion": "1.0",
                "type": "aws_proxy",
                "httpMethod": "POST",
                "uri": "arn:aws:apigateway:${region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${region}:${account_id}:function:${lambda_session_handler}/invocations",
                "connectionType": "INTERNET"
            }
        }
    },
    "paths": {
        "/{proxy+}": {
            "post": {
                "description": "Proxy Endpoint for all requests",
                "summary": "We want all requests to be proxied to our own sessionHandler Lambda to use our own OIDC provider.",
                "responses": {
                    "200": {
                        "description": "Success"
                    },
                    "400": {
                        "description": "Error"
                    },
                    "500": {
                        "description": "internal server error"
                    }
                },
                "parameters": [],
                "security": [],
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            },
            "get": {
                "description": "Proxy Endpoint for all requests",
                "summary": "We want all requests to be proxied to our own sessionHandler Lambda to use our own OIDC provider.",
                "responses": {
                    "200": {
                        "description": "Success"
                    },
                    "400": {
                        "description": "Error"
                    },
                    "500": {
                        "description": "internal server error"
                    }
                },
                "parameters": [],
                "security": [],
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/oauth2/forgot-password": {
            "post": {
                "description": "Forgot Password Endpoint",
                "summary": "",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "anonymizedEmail": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "internal server error"
                    }
                },
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/oauth2/interaction-finished": {
            "get": {
                "description": "Interaction Finished Endpoint",
                "summary": "The provider finishes the interaction (e.g. after password change).",
                "responses": {
                    "200": {
                        "description": "Success - Interacion was finished"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "parameters": [],
                "security": [],
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/oauth2/interaction-canceled": {
            "get": {
                "description": "Interaction Cancled Endpoint",
                "summary": "The provider canceles the interaction if the user navigates back to the application.",
                "responses": {
                    "200": {
                        "description": "Success - Interacion was canceled",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error getting password policy"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "parameters": [],
                "security": [],
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/oauth2/password/policy": {
            "get": {
                "description": "Password Policy Endpoint",
                "summary": "The frontend needs to know the password policy for validation. This endpoint returns the password policy.",
                "responses": {
                    "200": {
                        "description": "Succes - returning the password policy",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/PasswordPolicy"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error getting password policy"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "parameters": [],
                "security": [],
                "x-amazon-apigateway-integration": {
                    "payloadFormatVersion": "1.0",
                    "type": "aws_proxy",
                    "httpMethod": "POST",
                    "uri": "arn:aws:apigateway:${region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${region}:${account_id}:function:${lambda_password_policy}/invocations",
                    "connectionType": "INTERNET"
                }
            }
        },
        "/oauth2/user-details": {
            "get": {
                "description": "User Details Endpoint",
                "summary": "The frontend needs to know the user details. This endpoint returns the user details for a session.",
                "responses": {
                    "200": {
                        "description": "Success - returning the user details",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UserDetailsResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error getting user details"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/oauth2/update-locale": {
            "post": {
                "description": "Update Locale Endpoint",
                "summary": "This endpoint updates the locale of the user.",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/UpdateLocalePayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success"
                    },
                    "400": {
                        "description": "Error updating locale"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/missing-user-data/finished": {
            "post": {
                "description": "Contact Data Finished Endpoint",
                "summary": "The endpoint updates the user details in cognito and redirects the user to the url generated by the oidc provider.",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/UserDetails"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success - returning the url to redirect to",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error while updating user details and creating interaction result"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/register-company/finished": {
            "post": {
                "description": "Register company finished endpoint",
                "summary": "The endpoint creates the interaction result for the registration step 2 and redirects the user to the url generated by the oidc provider.",
                "responses": {
                    "200": {
                        "description": "Success - returning the url to redirect to",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error while creating interaction result"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/login/finished": {
            "post": {
                "description": "Endpoint to the login process",
                "summary": "The endpoint creates the interaction result for the login and redirects the user to the url generated by the oidc provider.",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/IdTokenPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success - returning the url to redirect to",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error while updating user details and creating interaction result"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/set-password/finished": {
            "post": {
                "description": "Set Password Finished Endpoint",
                "summary": "The endpoint updates the user group in cognito and redirects the user to the url generated by the oidc provider.",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/IdTokenPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success - returning the url to redirect to",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UrlResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error while updating user details and creating interaction result"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        },
        "/login/external": {
            "get": {
                "description": "Endpoint to the login process with an external provider",
                "summary": "The endpoint redirects the user to the external login UI.",
                "responses": {
                    "200": {
                        "description": "Success - returning the url to redirect to"
                    },
                    "400": {
                        "description": "Error while redirecting to external provider"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "x-amazon-apigateway-integration": {
                    "$ref": "#/components/x-amazon-apigateway-integrations/sessionHandler"
                }
            }
        }
    }
}
