From e4803977c0dc6be1a88abfcbe5bd2d1accdd3b78 Mon Sep 17 00:00:00 2001 From: Emilien GUILMINEAU Date: Sat, 30 Mar 2024 20:47:03 +0100 Subject: [PATCH] :children_crossing: Add a link to web view Allowing usage of the password into a subsystem which target human --- README.rst | 4 +++- snappass/main.py | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 8c55ce5..6e98da7 100644 --- a/README.rst +++ b/README.rst @@ -151,11 +151,13 @@ This will return a JSON response with a token and the password link: :: { - "token": "snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY%3D", "token": "snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY=", "links": [{ "rel": "self", "href": "http://127.0.0.1:5000/api/v2/passwords/snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY%3D", + },{ + "rel": "web-view", + "href": "http://127.0.0.1:5000/snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY%3D", }], "ttl":1209600 } diff --git a/snappass/main.py b/snappass/main.py index 9b04690..6f06572 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -282,13 +282,16 @@ def api_v2_set_password(): token = set_password(password, ttl) url_token = quote_plus(token) base_url = set_base_url(request) - link = urljoin(base_url, request.path + "/" + url_token) + api_link = urljoin(base_url, request.path + "/" + url_token) + web_link = urljoin(base_url, url_token) response_content = { - "token": url_token, "token": token, "links": [{ "rel": "self", - "href": link + "href": api_link + }, { + "rel": "web-view", + "href": web_link }], "ttl": ttl }