{
    "openapi": "3.0.3",
    "info": {
        "title": "password_policy",
        "version": "0.0.1",
        "description": "Allows admins to configure a password policy",
        "license": {
            "name": "agpl"
        }
    },
    "components": {
        "securitySchemes": {
            "basic_auth": {
                "type": "http",
                "scheme": "basic"
            },
            "bearer_auth": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "schemas": {
            "Capabilities": {
                "type": "object",
                "required": [
                    "password_policy"
                ],
                "properties": {
                    "password_policy": {
                        "type": "object",
                        "required": [
                            "api",
                            "policies",
                            "minLength",
                            "enforceNonCommonPassword",
                            "enforceNumericCharacters",
                            "enforceSpecialCharacters",
                            "enforceUpperLowerCase"
                        ],
                        "properties": {
                            "api": {
                                "type": "object",
                                "required": [
                                    "generate",
                                    "validate"
                                ],
                                "properties": {
                                    "generate": {
                                        "type": "string"
                                    },
                                    "validate": {
                                        "type": "string"
                                    }
                                }
                            },
                            "policies": {
                                "type": "object",
                                "additionalProperties": {
                                    "type": "object",
                                    "required": [
                                        "minLength",
                                        "enforceHaveIBeenPwned",
                                        "enforceNonCommonPassword",
                                        "enforceNumericCharacters",
                                        "enforceSpecialCharacters",
                                        "enforceUpperLowerCase"
                                    ],
                                    "properties": {
                                        "minLength": {
                                            "type": "integer",
                                            "format": "int64",
                                            "minimum": 0
                                        },
                                        "enforceHaveIBeenPwned": {
                                            "type": "boolean"
                                        },
                                        "enforceNonCommonPassword": {
                                            "type": "boolean"
                                        },
                                        "enforceNumericCharacters": {
                                            "type": "boolean"
                                        },
                                        "enforceSpecialCharacters": {
                                            "type": "boolean"
                                        },
                                        "enforceUpperLowerCase": {
                                            "type": "boolean"
                                        }
                                    }
                                }
                            },
                            "minLength": {
                                "type": "integer",
                                "format": "int64",
                                "minimum": 0
                            },
                            "enforceNonCommonPassword": {
                                "type": "boolean"
                            },
                            "enforceNumericCharacters": {
                                "type": "boolean"
                            },
                            "enforceSpecialCharacters": {
                                "type": "boolean"
                            },
                            "enforceUpperLowerCase": {
                                "type": "boolean"
                            }
                        }
                    }
                }
            },
            "OCSMeta": {
                "type": "object",
                "required": [
                    "status",
                    "statuscode"
                ],
                "properties": {
                    "status": {
                        "type": "string"
                    },
                    "statuscode": {
                        "type": "integer"
                    },
                    "message": {
                        "type": "string"
                    },
                    "totalitems": {
                        "type": "string"
                    },
                    "itemsperpage": {
                        "type": "string"
                    }
                }
            }
        }
    },
    "paths": {
        "/ocs/v2.php/apps/password_policy/api/v1/generate": {
            "get": {
                "operationId": "api-generate",
                "summary": "Generate a random password that validates against the enabled password policy rules",
                "tags": [
                    "api"
                ],
                "security": [
                    {
                        "bearer_auth": []
                    },
                    {
                        "basic_auth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "OCS-APIRequest",
                        "in": "header",
                        "description": "Required to be true for the API request to pass",
                        "required": true,
                        "schema": {
                            "type": "boolean",
                            "default": true
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Password generated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {
                                                    "type": "object",
                                                    "required": [
                                                        "password"
                                                    ],
                                                    "properties": {
                                                        "password": {
                                                            "type": "string"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Generated password accidentally failed to validate against the rules, retry.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {}
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/ocs/v2.php/apps/password_policy/api/v1/validate": {
            "post": {
                "operationId": "api-validate",
                "summary": "Validate a password against the enabled password policy rules",
                "tags": [
                    "api"
                ],
                "security": [
                    {
                        "bearer_auth": []
                    },
                    {
                        "basic_auth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "password"
                                ],
                                "properties": {
                                    "password": {
                                        "type": "string",
                                        "description": "The password to validate"
                                    }
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "OCS-APIRequest",
                        "in": "header",
                        "description": "Required to be true for the API request to pass",
                        "required": true,
                        "schema": {
                            "type": "boolean",
                            "default": true
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Always",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {
                                                    "type": "object",
                                                    "required": [
                                                        "passed"
                                                    ],
                                                    "properties": {
                                                        "passed": {
                                                            "type": "boolean"
                                                        },
                                                        "reason": {
                                                            "type": "string"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "tags": []
}
