Files
notifications-api/app/user/users_schema.py
Katie Smith b440f3f904 Use Draft-07 and Draft7Validator everywhere
We were using the Draft4Validator in one place, so this updates it to
the Draft7Validator instead.

The schemas were mostly using draft 4 of the JSON schema, though there
were a couple of schemas that were already of version 7. This updates
them all to version 7, which is the latest version fully supported by
the jsonschema Python package. There are some breaking changes in the
newer version of the schema, but I could not see anywhere would these
affect us. Some of these schemas were not valid in version 4, but are
now valid in version 7 because `"required": []` was not valid in earlier
versions.
2022-04-14 14:46:10 +01:00

68 lines
2.0 KiB
Python

post_verify_code_schema = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST schema for verifying a 2fa code',
'type': 'object',
'properties': {
'code': {'type': 'string'},
'code_type': {'type': 'string'},
},
'required': ['code', 'code_type'],
'additionalProperties': False
}
post_verify_webauthn_schema = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST schema for verifying a webauthn login attempt',
'type': 'object',
'properties': {
'successful': {'type': 'boolean'}
},
'required': ['successful'],
'additionalProperties': False
}
post_send_user_email_code_schema = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': (
'POST schema for generating a 2fa email - "to" is required for legacy purposes. '
'"next" is an optional url to redirect to on sign in'
),
'type': 'object',
'properties': {
# doesn't need 'to' as we'll just grab user.email_address. but lets keep it
# as allowed to keep admin code cleaner, but only as null to prevent confusion
'to': {'type': 'null'},
'email_auth_link_host': {'type': ['string', 'null']},
'next': {'type': ['string', 'null']},
},
'required': [],
'additionalProperties': False
}
post_send_user_sms_code_schema = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'description': 'POST schema for generating a 2fa sms',
'type': 'object',
'properties': {
'to': {'type': ['string', 'null']},
},
'required': [],
'additionalProperties': False
}
post_set_permissions_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST schema for setting user permissions",
"type": "object",
"properties": {
"permissions": {"type": "array", "items": {"type": "object"}},
"folder_permissions": {"type": "array", "items": {"type": "string"}}
},
"required": ["permissions"],
"additionalProperties": False
}