Skip to content

Commit

Permalink
add "/" endpoint to document the other endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvs committed Mar 27, 2020
1 parent f1c45c0 commit 42e6767
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
30 changes: 24 additions & 6 deletions example-aio.py
@@ -1,5 +1,5 @@
# MIT License{{{
#
# vim: tw=100 foldmethod=marker
# MIT License#
# Copyright (c) 2017 - 2019 Karlsruhe Institute of Technology - Steinbuch Centre for Computing
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -18,12 +18,11 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.}}}
# pylint # {{{
# vim: tw=100 foldmethod=marker
# SOFTWARE.
# pylint
# pylint: disable=bad-continuation, invalid-name, superfluous-parens
# pylint: disable=bad-whitespace, missing-docstring
# }}}
#
import os
import logging
from flaat import Flaat
Expand Down Expand Up @@ -88,6 +87,25 @@
def my_failure_callback(message=''):
return 'User define failure callback.\nError Message: "%s"' % message

@routes.get('/')
async def root(request):
text = '''This is an example for useing flaat with AIO. These endpoints are available:
/info General info about the access_token (if provided)
/valid_user Requires a valid user
/valid_user_2 Requires a valid user, uses a custom callback on error
/group_test_kit Requires user to have two "eduperson_scoped_affiliation" of
['admins@kit.edu', 'employee@kit.edu', 'member@kit.edu'],
/group_test_iam Requires user to be in the group "KIT-Cloud" transported in "groups"
/group_test_hdf Requires user to be in all groups found in "eduperson_entitlement"
['urn:geant:h-df.de:group:aai-admin', 'urn:geant:h-df.de:group:myExampleColab#unity.helmholtz-data-federation.de']
/group_test_hdf2 Requires user to be in all groups found in "eduperson_entitlement"
['urn:geant:h-df.de:group:myExampleColab#unity.helmholtz-data-federation.de'],
/group_test_hdf3 Requires user to be in all groups found in "eduperson_entitlement"
['urn:geant:h-df.de:group:aai-admin'],
'''
return web.Response(text=text)

@routes.get('/info')
async def info(request):
access_token = tokentools.get_access_token_from_request(request)
Expand Down
19 changes: 19 additions & 0 deletions example-flask.py
Expand Up @@ -87,6 +87,25 @@
def my_failure_callback(message=''):
return 'User define failure callback.\nError Message: "%s"' % message

@app.route('/')
def root():
text = '''This is an example for useing flaat with AIO. These endpoints are available:
/info General info about the access_token (if provided)
/valid_user Requires a valid user
/valid_user_2 Requires a valid user, uses a custom callback on error
/group_test_kit Requires user to have two "eduperson_scoped_affiliation" of
['admins@kit.edu', 'employee@kit.edu', 'member@kit.edu'],
/group_test_iam Requires user to be in the group "KIT-Cloud" transported in "groups"
/group_test_hdf Requires user to be in all groups found in "eduperson_entitlement"
['urn:geant:h-df.de:group:aai-admin', 'urn:geant:h-df.de:group:myExampleColab#unity.helmholtz-data-federation.de']
/group_test_hdf2 Requires user to be in all groups found in "eduperson_entitlement"
['urn:geant:h-df.de:group:myExampleColab#unity.helmholtz-data-federation.de'],
/group_test_hdf3 Requires user to be in all groups found in "eduperson_entitlement"
['urn:geant:h-df.de:group:aai-admin'],
'''
return (text)

@app.route('/info')
def info():
access_token = tokentools.get_access_token_from_request(request)
Expand Down

0 comments on commit 42e6767

Please sign in to comment.