Skip to content

Commit

Permalink
Merge branch 'dev' into v5updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpricethesecond authored Jun 24, 2024
2 parents 57941dd + 32338b9 commit f8495f8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM tapis/flaskbase:1.5.0
FROM tapis/flaskbase:1.6.3

ADD requirements.txt /home/tapis/requirements.txt
RUN pip install -r /home/tapis/requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ services:

networks:
tapis:
external: true
external: true
14 changes: 14 additions & 0 deletions service/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,17 @@ def __init__(self, url_map, *items):
api.add_resource(ReadyResource, '/v3/globus-proxy/ready')
api.add_resource(HealthcheckResource, '/v3/globus-proxy/healthcheck')
api.add_resource(HelloResource, '/v3/globus-proxy/hello')

@app.before_request
def log_before():
logger.debug(f'Beginning new request:: {request}')
if request.json:
logger.debug(f'json:: {request.json}')

@app.after_request
def log_after(response):
# logger.debug(f'request complete with status:: {response.data['status']}')
logger.debug(f'request complete with status:: {response.status}\n')
if response.status == '500 INTERNAL SERVER ERROR':
print(f'its all messed up')
return response
6 changes: 5 additions & 1 deletion service/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def authn_and_authz():
:return:
"""
# skip_sk = False
logger.debug(f'in authn and authz for tapis')
authentication()
#authorization(skip_sk)

Expand All @@ -28,7 +29,7 @@ def authentication():
# authorization.
# we always try to call the primary tapis authentication function to add authentication information to the
# thread-local. If it fails due to a missing token, we then check if there is a public endpoint
logger.debug(request.headers)
logger.debug(f'in tapis authentication with {request.headers}')
try:
tapisflask.auth.authentication()
logger.debug(f"Threadlocal tenant id: "+str(conf.tenant[g.tenant_id]))
Expand All @@ -46,6 +47,9 @@ def authentication():
g.tenant_id = request.args.get('tenant')
logger.debug(f"Threadlocal tenant id: "+str(g.tenant_id))
return True
except Exception as e:
logger.error(e)
print(e)

# this is the Tapis client that tenants will use for interacting with other services, such as the security kernel.
Tenants = TenantCache()
Expand Down
1 change: 1 addition & 0 deletions service/controllers/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def get(self, client_id, endpoint_id, path):

# mkdir
def do_mkdir(self, transfer_client, endpoint_id, path):
logger.debug(f'In do_mkdir with {endpoint_id}:{path}')
result = transfer_client.operation_mkdir(
endpoint_id=endpoint_id,
path=path
Expand Down
5 changes: 5 additions & 0 deletions service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ def format_path(path, default_dir=None):

return f"/{path.rstrip('/').lstrip('/')}"


def get_collection_id(client_id, client_secret, name):
client = get_transfer_client_with_secret(client_id, client_secret)
result = client.endpoint_search(filter_fulltext=name, filter_non_functional=False, limit=1)
# print(f'have result:: {result["DATA"][0]["id"]}')
return result["DATA"][0]["id"]


def get_transfer_client(client_id, refresh_token, access_token):
logger.debug(f'Attempting auth for client {client_id} using token')
print(f'Attempting auth for client {client_id} using token')
Expand All @@ -135,9 +137,11 @@ def get_transfer_client(client_id, refresh_token, access_token):
access_token=access_token,
expires_at=expires_at
)
get_token_introspect(client_id, refresh_token)
transfer_client = globus_sdk.TransferClient(authorizer=authorizer)
return transfer_client


def get_transfer_client_with_secret(client_id, client_secret, endpoint_id=None, addl_scopes=None):
logger.debug(f'Attempting auth for client {client_id} using secret')
try:
Expand Down Expand Up @@ -167,6 +171,7 @@ def get_transfer_client_with_secret(client_id, client_secret, endpoint_id=None,
logger.debug(f'got client: {transfer_client} with endpoint: {endpoint_id} and scopes: {scopes}')
return transfer_client


def get_valid_token(client_id, refresh_token):
'''
Utility function that takes a client id and refresh token
Expand Down

0 comments on commit f8495f8

Please sign in to comment.