Skip to content

Commit

Permalink
add more readable operationId and response types, fix deps
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt committed Nov 28, 2024
1 parent 7daa0e3 commit 2cb4993
Show file tree
Hide file tree
Showing 25 changed files with 4,628 additions and 4,587 deletions.
8,830 changes: 4,380 additions & 4,450 deletions docs/api/openapidocs.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions lib/api/2fa/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/custom',
tags: ['TwoFactorAuth'],
summary: 'Enable custom 2FA for a user',
name: 'enableCustom2FA',
description: 'This method disables account password for IMAP/POP3/SMTP',
validationObjs: {
requestBody: {
Expand All @@ -25,7 +26,7 @@ module.exports = (db, server, userHandler) => {
},
queryParams: {},
pathParams: { user: userId },
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
}
},
tools.responseWrapper(async (req, res) => {
Expand Down Expand Up @@ -74,6 +75,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/custom',
tags: ['TwoFactorAuth'],
summary: 'Disable custom 2FA for a user',
name: 'disableCustom2FA',
description: 'This method disables custom 2FA. If it was the only 2FA set up, then account password for IMAP/POP3/SMTP gets enabled again',
validationObjs: {
requestBody: {},
Expand All @@ -82,7 +84,7 @@ module.exports = (db, server, userHandler) => {
ip: sessIPSchema
},
pathParams: { user: userId },
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
}
},
tools.responseWrapper(async (req, res) => {
Expand Down
15 changes: 10 additions & 5 deletions lib/api/2fa/totp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/totp/setup',
tags: ['TwoFactorAuth'],
summary: 'Generate TOTP seed',
name: 'generateTOTPSeed',
description: 'This method generates TOTP seed and QR code for 2FA. User needs to verify the seed value using 2fa/totp/enable endpoint',
validationObjs: {
requestBody: {
Expand All @@ -33,7 +34,7 @@ module.exports = (db, server, userHandler) => {
success: successRes,
seed: Joi.string().required().description('Generated TOTP seed value'),
qrcode: Joi.string().required().description('Base64 encoded QR code')
})
}).$_setFlag('objectName', 'GenerateTOTPSeedResponse')
}
}
}
Expand Down Expand Up @@ -86,6 +87,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/totp/enable',
tags: ['TwoFactorAuth'],
summary: 'Enable TOTP seed',
name: 'enableTOTPSeed',
description: 'This method enables TOTP for a user by verifying the seed value generated from 2fa/totp/setup',
validationObjs: {
requestBody: {
Expand All @@ -95,7 +97,7 @@ module.exports = (db, server, userHandler) => {
},
queryParams: {},
pathParams: { user: userId },
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
}
},
tools.responseWrapper(async (req, res) => {
Expand Down Expand Up @@ -161,12 +163,13 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/totp',
tags: ['TwoFactorAuth'],
summary: 'Disable TOTP auth',
name: 'disableTOTPAuth',
description: 'This method disables TOTP for a user. Does not affect other 2FA mechanisms a user might have set up',
validationObjs: {
requestBody: {},
queryParams: { sess: sessSchema, ip: sessIPSchema },
pathParams: { user: userId },
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
}
},
tools.responseWrapper(async (req, res) => {
Expand Down Expand Up @@ -215,6 +218,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/totp/check',
tags: ['TwoFactorAuth'],
summary: 'Validate TOTP Token',
name: 'validateTOTPToken',
description: 'This method checks if a TOTP token provided by a User is valid for authentication',
validationObjs: {
requestBody: {
Expand All @@ -224,7 +228,7 @@ module.exports = (db, server, userHandler) => {
},
queryParams: {},
pathParams: { user: userId },
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
}
},
tools.responseWrapper(async (req, res) => {
Expand Down Expand Up @@ -281,6 +285,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa',
tags: ['TwoFactorAuth'],
summary: 'Disable 2FA',
name: 'disable2FA',
description: 'This method disables all 2FA mechanisms a user might have set up',
validationObjs: {
requestBody: {},
Expand All @@ -289,7 +294,7 @@ module.exports = (db, server, userHandler) => {
ip: sessIPSchema
},
pathParams: { user: userId },
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
}
},
tools.responseWrapper(async (req, res) => {
Expand Down
18 changes: 12 additions & 6 deletions lib/api/2fa/webauthn.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/webauthn/credentials',
tags: ['TwoFactorAuth'],
summary: 'Get WebAuthN credentials for a user',
name: 'getWebAuthN',
description: 'This method returns the list of WebAuthN credentials for a given user',
validationObjs: {
requestBody: {},
Expand Down Expand Up @@ -43,7 +44,7 @@ module.exports = (db, server, userHandler) => {
)
.required()
.description('List of credentials')
})
}).$_setFlag('objectName', 'GetWebAuthNResponse')
}
}
}
Expand Down Expand Up @@ -115,6 +116,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/webauthn/credentials/:credential',
tags: ['TwoFactorAuth'],
summary: 'Remove WebAuthN authenticator',
name: 'deleteWebAuthN',
description: 'This method deletes the given WebAuthN authenticator for given user.',
validationObjs: {
requestBody: {},
Expand All @@ -132,7 +134,7 @@ module.exports = (db, server, userHandler) => {
model: Joi.object({
success: successRes,
deleted: booleanSchema.required().description('Specifies whether the given credential has been deleted')
})
}).$_setFlag('objectName', 'DeleteWebAuthNResponse')
}
}
}
Expand Down Expand Up @@ -187,6 +189,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/webauthn/registration-challenge',
tags: ['TwoFactorAuth'],
summary: 'Get the WebAuthN registration challenge',
name: 'initiateWebAuthNRegistration',
description: 'This method initiates the WebAuthN authenticator registration challenge',
validationObjs: {
requestBody: {
Expand Down Expand Up @@ -247,7 +250,7 @@ module.exports = (db, server, userHandler) => {
)
.description('List of credentials to exclude')
})
})
}).$_setFlag('objectName', 'InitiateWebAuthNRegistrationResponse')
}
}
}
Expand Down Expand Up @@ -299,6 +302,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/webauthn/registration-attestation',
tags: ['TwoFactorAuth'],
summary: 'Attestate WebAuthN authenticator',
name: 'attestateWebAuthNRegistration',
description: 'Attestation is used to verify the authenticity of the authenticator and provide assurances about its features.',
validationObjs: {
requestBody: {
Expand Down Expand Up @@ -333,7 +337,7 @@ module.exports = (db, server, userHandler) => {
rawId: Joi.string().hex().required().description('Credential RawID as a hex string'),
description: Joi.string().required().description('Description for the authenticator'),
authenticatorAttachment: Joi.string().required().description('Specifies whether authenticator is "platform" or "cross-platform"')
})
}).$_setFlag('objectName', 'AttestateWebAuthNRegistrationResponse')
}
}
}
Expand Down Expand Up @@ -387,6 +391,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/webauthn/authentication-challenge',
tags: ['TwoFactorAuth'],
summary: 'Begin WebAuthN authentication challenge',
name: 'authenticateWebAuthN',
description: 'This method retrieves the WebAuthN PublicKeyCredentialRequestOptions object to use it for authentication',
validationObjs: {
requestBody: {
Expand Down Expand Up @@ -431,7 +436,7 @@ module.exports = (db, server, userHandler) => {
})
.required()
.description('PublicKeyCredentialRequestOptions object')
})
}).$_setFlag('objectName', 'AuthenticateWebAuthNResponse')
}
}
}
Expand Down Expand Up @@ -483,6 +488,7 @@ module.exports = (db, server, userHandler) => {
path: '/users/:user/2fa/webauthn/authentication-assertion',
tags: ['TwoFactorAuth'],
summary: 'WebAuthN authentication Assertion',
name: 'assertWebAuthN',
description: 'Assert WebAuthN authentication request and actually authenticate the user',
validationObjs: {
requestBody: {
Expand Down Expand Up @@ -529,7 +535,7 @@ module.exports = (db, server, userHandler) => {
.required()
.description('Auth data'),
token: Joi.string().description('User auth token')
})
}).$_setFlag('objectName', 'AssertWebAuthNResponse')
}
}
}
Expand Down
Loading

0 comments on commit 2cb4993

Please sign in to comment.