Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrmn committed Jun 19, 2019
1 parent 48923c6 commit 7312513
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

.vscode/

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ A **new** bunch of middleware functions to build applications on top of CARTO.
- [ ] Documentation

- [ ] OAuth
- [x] OAuth2 with Carto (onprem)
- [ ] Role mapping
- [ ] Token storage
- [ ] Documentation
Expand Down
9 changes: 9 additions & 0 deletions longitude/aiohttp/carto_oauth2_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ def user_parse(data):

async def login_process(self, request, session_register_cb=None, referer_url_params_cb=None, error_cb=None):
"""Login helper for Carto OAuth2 process.
If the login process was successful, then two options:
* If request.headers.get('Referer') was set, then the function will redirect to this URL adding a few
arguments to the URL (@see referer_url_params_cb below).
* Othercase the session data will be returned as JSON with `web.json_response(session_data)`
In case of errors, the error callback will be called (@see error_cb below), or an error response will
be returned as JSON with `aiohttp.web.json_response` function.
@see `longitude/samples` folder for usage examples.
@param request - AioHttp request object.
Expand Down
3 changes: 3 additions & 0 deletions longitude/samples/aiohttp_oauth2_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

"""
Minimal Carto-OAuth2 working example.
More details about this at `longitude/aiohttp/carto_oauth2_client.py`
You'll need an onpremises instance of Carto and a pre-configured app:
@see https://docs.google.com/document/d/1dvdZuBF7J5fQiV6Wh1s40_gPAqFjIwtgDu1E6VBav5s
Expand Down Expand Up @@ -75,6 +76,8 @@ async def user_logout(request):
access_token = request.headers.get('Authorization') or request.headers.get('x-auth-token')
await delete_session(access_token)
return web.json_response({'status': 'ok', 'msg': 'Bye'})
# In order to logout from Carto, you must redirect to the following URL instead:
# web.HTTPFound(f'https://{base_url}/user/{username}/logout')
# End login management ------------------


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "geographica-longitude"
packages = [
{ include='longitude' }
]
version = "0.9.2"
version = "0.9.3"
description = "A longitudinal lib"
authors = ["Geographica <[email protected]>"]
homepage = "https://github.com/GeographicaGS/Longitude"
Expand Down

0 comments on commit 7312513

Please sign in to comment.