kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Defined auth API
rodzic
5f0c6c62d5
commit
0e7830f26b
104
docs/index.adoc
104
docs/index.adoc
|
@ -8,7 +8,7 @@ REST API to access ODM
|
|||
|
||||
=== Version information
|
||||
[%hardbreaks]
|
||||
_Version_ : 1.2.2
|
||||
_Version_ : 1.3.0
|
||||
|
||||
|
||||
=== Contact information
|
||||
|
@ -43,6 +43,108 @@ _Schemes_ : HTTP
|
|||
[[_paths]]
|
||||
== Paths
|
||||
|
||||
[[_auth_login_post]]
|
||||
=== POST /auth/login
|
||||
|
||||
==== Description
|
||||
Retrieve a token from a username/password pair.
|
||||
|
||||
|
||||
==== Parameters
|
||||
|
||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
||||
|===
|
||||
|Type|Name|Description|Schema|Default
|
||||
|*Body*|*password* +
|
||||
_required_|Password|string|
|
||||
|*Body*|*username* +
|
||||
_required_|Username|string|
|
||||
|===
|
||||
|
||||
|
||||
==== Responses
|
||||
|
||||
[options="header", cols=".^2,.^14,.^4"]
|
||||
|===
|
||||
|HTTP Code|Description|Schema
|
||||
|*200*|Login Succeeded|<<_auth_login_post_response_200,Response 200>>
|
||||
|*default*|Error|<<_error,Error>>
|
||||
|===
|
||||
|
||||
[[_auth_login_post_response_200]]
|
||||
*Response 200*
|
||||
|
||||
[options="header", cols=".^3,.^11,.^4"]
|
||||
|===
|
||||
|Name|Description|Schema
|
||||
|*token* +
|
||||
_required_|Token to be passed as a query parameter to other API calls.|string
|
||||
|===
|
||||
|
||||
|
||||
[[_auth_login_get]]
|
||||
=== GET /auth/login
|
||||
|
||||
==== Description
|
||||
Retrieves login information for this node.
|
||||
|
||||
|
||||
==== Responses
|
||||
|
||||
[options="header", cols=".^2,.^14,.^4"]
|
||||
|===
|
||||
|HTTP Code|Description|Schema
|
||||
|*200*|LoginInformation|<<_auth_login_get_response_200,Response 200>>
|
||||
|===
|
||||
|
||||
[[_auth_login_get_response_200]]
|
||||
*Response 200*
|
||||
|
||||
[options="header", cols=".^3,.^11,.^4"]
|
||||
|===
|
||||
|Name|Description|Schema
|
||||
|*instructions* +
|
||||
_optional_|Message to be displayed to the user prior to login/registration. This might include instructions on how to register or login, or to communicate that authentication is not available.|string
|
||||
|*loginUrl* +
|
||||
_required_|URL (absolute or relative) where to make a POST request to obtain a token, or null if login is disabled.|string
|
||||
|*registerUrl* +
|
||||
_required_|URL (absolute or relative) where to make a POST request to register a user, or null if registration is disabled.|string
|
||||
|===
|
||||
|
||||
|
||||
==== Tags
|
||||
|
||||
* auth
|
||||
|
||||
|
||||
[[_auth_register_post]]
|
||||
=== POST /auth/register
|
||||
|
||||
==== Description
|
||||
Register a new username/password.
|
||||
|
||||
|
||||
==== Parameters
|
||||
|
||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
||||
|===
|
||||
|Type|Name|Description|Schema|Default
|
||||
|*Body*|*password* +
|
||||
_required_|Password|string|
|
||||
|*Body*|*username* +
|
||||
_required_|Username|string|
|
||||
|===
|
||||
|
||||
|
||||
==== Responses
|
||||
|
||||
[options="header", cols=".^2,.^14,.^4"]
|
||||
|===
|
||||
|HTTP Code|Description|Schema
|
||||
|*200*|Response|<<_response,Response>>
|
||||
|===
|
||||
|
||||
|
||||
[[_info_get]]
|
||||
=== GET /info
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
96
index.js
96
index.js
|
@ -721,6 +721,102 @@ app.get('/info', authCheck, (req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
/** @swagger
|
||||
* /auth/login:
|
||||
* get:
|
||||
* description: Retrieves login information for this node.
|
||||
* tags: [auth]
|
||||
* responses:
|
||||
* 200:
|
||||
* description: LoginInformation
|
||||
* schema:
|
||||
* type: object
|
||||
* required: [message, loginUrl, registerUrl]
|
||||
* properties:
|
||||
* instructions:
|
||||
* type: string
|
||||
* description: Message to be displayed to the user prior to login/registration. This might include instructions on how to register or login, or to communicate that authentication is not available.
|
||||
* loginUrl:
|
||||
* type: string
|
||||
* description: URL (absolute or relative) where to make a POST request to obtain a token, or null if login is disabled.
|
||||
* registerUrl:
|
||||
* type: string
|
||||
* description: URL (absolute or relative) where to make a POST request to register a user, or null if registration is disabled.
|
||||
*/
|
||||
app.get('/auth/info', (req, res) => {
|
||||
res.json({
|
||||
message: "Authentication not available on this node",
|
||||
loginUrl: null,
|
||||
registerUrl: null
|
||||
});
|
||||
});
|
||||
|
||||
/** @swagger
|
||||
* /auth/login:
|
||||
* post:
|
||||
* description: Retrieve a token from a username/password pair.
|
||||
* parameters:
|
||||
* -
|
||||
* name: username
|
||||
* in: body
|
||||
* description: Username
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* -
|
||||
* name: password
|
||||
* in: body
|
||||
* description: Password
|
||||
* required: true
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Login Succeeded
|
||||
* schema:
|
||||
* type: object
|
||||
* required: [token]
|
||||
* properties:
|
||||
* token:
|
||||
* type: string
|
||||
* description: Token to be passed as a query parameter to other API calls.
|
||||
* default:
|
||||
* description: Error
|
||||
* schema:
|
||||
* $ref: '#/definitions/Error'
|
||||
*/
|
||||
app.post('/auth/login', (req, res) => {
|
||||
res.json({error: "Not available"});
|
||||
});
|
||||
|
||||
/** @swagger
|
||||
* /auth/register:
|
||||
* post:
|
||||
* description: Register a new username/password.
|
||||
* parameters:
|
||||
* -
|
||||
* name: username
|
||||
* in: body
|
||||
* description: Username
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* -
|
||||
* name: password
|
||||
* in: body
|
||||
* description: Password
|
||||
* required: true
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Response
|
||||
* schema:
|
||||
* $ref: "#/definitions/Response"
|
||||
*/
|
||||
app.post('/auth/register', (req, res) => {
|
||||
res.json({error: "Not available"});
|
||||
});
|
||||
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
logger.error(err.stack);
|
||||
res.json({error: err.message});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "node-opendronemap",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.0",
|
||||
"description": "REST API to access ODM",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Ładowanie…
Reference in New Issue