mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-10-06 11:57:27 +08:00
v1.4.24
This commit is contained in:
parent
6a517c8ffb
commit
eb1a9b7c90
6 changed files with 133 additions and 7 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
define({
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2018-10-03T07:45:44.413Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
});
|
define({
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2018-10-08T08:02:16.146Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2018-10-03T07:45:44.413Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
}
|
{
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2018-10-08T08:02:16.146Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
}
|
||||||
|
|
126
lib/api/asps.js
126
lib/api/asps.js
|
@ -159,6 +159,132 @@ module.exports = (db, server, userHandler) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api {get} /users/:user/asps/:asp Request ASP information
|
||||||
|
* @apiName GetASP
|
||||||
|
* @apiGroup ApplicationPasswords
|
||||||
|
* @apiHeader {String} X-Access-Token Optional access token if authentication is enabled
|
||||||
|
* @apiHeaderExample {json} Header-Example:
|
||||||
|
* {
|
||||||
|
* "X-Access-Token": "59fc66a03e54454869460e45"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiParam {String} user ID of the User
|
||||||
|
* @apiParam {String} asp ID of the Application Specific Password
|
||||||
|
*
|
||||||
|
* @apiSuccess {Boolean} success Indicates successful response
|
||||||
|
* @apiSuccess {String} id ID of the Application Password
|
||||||
|
* @apiSuccess {String} description Description
|
||||||
|
* @apiSuccess {String[]} scopes Allowed scopes for the Application Password
|
||||||
|
* @apiSuccess {Object} lastUse Information about last use
|
||||||
|
* @apiSuccess {String} lastUse.time Datestring of last use or false if password has not been used
|
||||||
|
* @apiSuccess {String} lastUse.event Event ID of the security log for the last authentication
|
||||||
|
* @apiSuccess {String} created Datestring
|
||||||
|
*
|
||||||
|
* @apiError error Description of the error
|
||||||
|
*
|
||||||
|
* @apiExample {curl} Example usage:
|
||||||
|
* curl -i "http://localhost:8080/users/59fc66a03e54454869460e45/asps/5a1d6dd776e56b6d97e5dd48"
|
||||||
|
*
|
||||||
|
* @apiSuccessExample {json} Success-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "success": true,
|
||||||
|
* "id": "5a1d6dd776e56b6d97e5dd48",
|
||||||
|
* "description": "Thunderbird",
|
||||||
|
* "scopes": [
|
||||||
|
* "imap",
|
||||||
|
* "smtp"
|
||||||
|
* ],
|
||||||
|
* "lastUse": {
|
||||||
|
* "time": "2018-06-21T16:51:53.807Z",
|
||||||
|
* "event": "5b2bd7a9d0ba2509deb88f40"
|
||||||
|
* },
|
||||||
|
* "created": "2017-11-28T14:08:23.520Z"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiErrorExample {json} Error-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "error": "Database error"
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
server.get('/users/:user/asps/:asp', (req, res, next) => {
|
||||||
|
res.charSet('utf-8');
|
||||||
|
|
||||||
|
const schema = Joi.object().keys({
|
||||||
|
user: Joi.string()
|
||||||
|
.hex()
|
||||||
|
.lowercase()
|
||||||
|
.length(24)
|
||||||
|
.required(),
|
||||||
|
asp: Joi.string()
|
||||||
|
.hex()
|
||||||
|
.lowercase()
|
||||||
|
.length(24)
|
||||||
|
.required(),
|
||||||
|
sess: Joi.string().max(255),
|
||||||
|
ip: Joi.string().ip({
|
||||||
|
version: ['ipv4', 'ipv6'],
|
||||||
|
cidr: 'forbidden'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = Joi.validate(req.params, schema, {
|
||||||
|
abortEarly: false,
|
||||||
|
convert: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
res.json({
|
||||||
|
error: result.error.message,
|
||||||
|
code: 'InputValidationError'
|
||||||
|
});
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
let user = new ObjectID(result.value.user);
|
||||||
|
let asp = new ObjectID(result.value.asp);
|
||||||
|
|
||||||
|
db.users.collection('asps').findOne(
|
||||||
|
{
|
||||||
|
_id: asp,
|
||||||
|
user
|
||||||
|
},
|
||||||
|
(err, asp) => {
|
||||||
|
if (err) {
|
||||||
|
res.json({
|
||||||
|
error: 'MongoDB Error: ' + err.message,
|
||||||
|
code: 'InternalDatabaseError'
|
||||||
|
});
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!asp) {
|
||||||
|
res.json({
|
||||||
|
error: 'Invalid or unknown ASP key',
|
||||||
|
code: 'AspNotFound'
|
||||||
|
});
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
id: asp._id,
|
||||||
|
description: asp.description,
|
||||||
|
scopes: asp.scopes.includes('*') ? [...consts.SCOPES] : asp.scopes,
|
||||||
|
lastUse: {
|
||||||
|
time: asp.used || false,
|
||||||
|
event: asp.authEvent || false
|
||||||
|
},
|
||||||
|
created: asp.created
|
||||||
|
});
|
||||||
|
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /users/:user/asps Create new Application Password
|
* @api {post} /users/:user/asps Create new Application Password
|
||||||
* @apiName PostASP
|
* @apiName PostASP
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "wildduck",
|
"name": "wildduck",
|
||||||
"version": "1.4.23",
|
"version": "1.4.24",
|
||||||
"description": "IMAP/POP3 server built with Node.js and MongoDB",
|
"description": "IMAP/POP3 server built with Node.js and MongoDB",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
"humanname": "0.2.2",
|
"humanname": "0.2.2",
|
||||||
"iconv-lite": "0.4.24",
|
"iconv-lite": "0.4.24",
|
||||||
"ioredfour": "1.0.2-ioredis-02",
|
"ioredfour": "1.0.2-ioredis-02",
|
||||||
"ioredis": "4.0.0",
|
"ioredis": "4.0.1",
|
||||||
"isemail": "3.1.3",
|
"isemail": "3.1.3",
|
||||||
"joi": "13.7.0",
|
"joi": "13.7.0",
|
||||||
"js-yaml": "3.12.0",
|
"js-yaml": "3.12.0",
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
"node-forge": "0.7.6",
|
"node-forge": "0.7.6",
|
||||||
"nodemailer": "4.6.8",
|
"nodemailer": "4.6.8",
|
||||||
"npmlog": "4.1.2",
|
"npmlog": "4.1.2",
|
||||||
"openpgp": "4.1.0",
|
"openpgp": "4.1.1",
|
||||||
"pem": "1.13.1",
|
"pem": "1.13.1",
|
||||||
"pwnedpasswords": "1.0.4",
|
"pwnedpasswords": "1.0.4",
|
||||||
"qrcode": "1.3.0",
|
"qrcode": "1.3.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue