xiazcy commented on code in PR #2731: URL: https://github.com/apache/tinkerpop/pull/2731#discussion_r1734042459
########## gremlin-python/src/main/python/gremlin_python/driver/auth.py: ########## @@ -0,0 +1,81 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +import abc + + +class Auth(metaclass=abc.ABCMeta): + + @abc.abstractmethod + def apply(self, request): + """Applies the necessary authentication operations to the request and returns the modified request.""" + pass + + @staticmethod + def basic(username, password): + return BasicAuth(username, password) + + @staticmethod + def sigv4(region_name, aws_access_key_id='', aws_secret_access_key='', session_token='', service_name=''): + return SigV4Auth(region_name, aws_access_key_id, aws_secret_access_key, session_token, service_name) + + +class BasicAuth(Auth): + + def __init__(self, username, password): + self._username = username + self._password = password + + def apply(self, request): + from aiohttp import BasicAuth as aiohttpBasicAuth + + return request['headers'].update({'authorization': aiohttpBasicAuth(self._username, self._password).encode()}) + + +class SigV4Auth(Auth): + + def __init__(self, region_name, aws_access_key_id='', aws_secret_access_key='', session_token='', + service_name=''): + import os + + self._region_name = region_name Review Comment: Region is still a required input for sigV4 signing, even with session.region_name, it looks like it needs to be a user input (or env variable). I'm leaning towards required user input (as with Java driver). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
