add endpoint for verifying webauthn login

with sms and email auth the api handles verifying logins in the
`/<user_id>/verify/code` endpoint, when it checks the code is valid etc.
The admin app has already done this for webauthn logins, but we still
need an API endpoint so that we can set up the user's db entry to have
a new logged in timestamp, a new session id (this is important for
logging out other browser sessions), etc.

Also, we need to be able to make sure that the user's max login count
isn't exceeded. If it's exceeded, we shouldn't let them log in even with
a valid webauthn check.

This endpoint is a POST where the admin passes in a json dict with key
"succesful" being True or False. True sets up the db stuff as mentioned.
False just increments the failed login count.
This commit is contained in:
Leo Hemsted
2021-05-17 20:32:01 +01:00
parent 3702d4eae8
commit 00b0227007
3 changed files with 107 additions and 3 deletions

View File

@@ -11,6 +11,18 @@ post_verify_code_schema = {
}
post_verify_webauthn_schema = {
'$schema': 'http://json-schema.org/draft-04/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-04/schema#',
'description': (