Merge pull request #63 from pierotofy/login

Login API
pull/66/head
Piero Toffanin 2018-12-21 15:40:37 -05:00 zatwierdzone przez GitHub
commit 21d9bd7ab6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
6 zmienionych plików z 201 dodań i 17 usunięć

Wyświetl plik

@ -37,7 +37,4 @@ COPY . /var/www
RUN npm install
RUN mkdir tmp
# Fix old version of gdal2tiles.py
# RUN (cd / && patch -p0) <patches/gdal2tiles.patch
ENTRYPOINT ["/usr/bin/nodejs", "/var/www/index.js"]

Wyświetl plik

@ -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

Wyświetl plik

@ -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});

Wyświetl plik

@ -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": {

Wyświetl plik

@ -1,11 +0,0 @@
--- /usr/bin/gdal2tiles.py 2014-04-05 14:21:17.000000000 +0000
+++ gdal2tiles.py 2016-11-08 19:33:42.162188732 +0000
@@ -783,7 +783,7 @@
self.out_srs = osr.SpatialReference()
if self.options.profile == 'mercator':
- self.out_srs.ImportFromEPSG(900913)
+ self.out_srs.ImportFromEPSG(3857)
elif self.options.profile == 'geodetic':
self.out_srs.ImportFromEPSG(4326)
else: