Skip to content

Commit

Permalink
Merge pull request #13 from christian-hawk/deepsource-fix-9f6cbe70
Browse files Browse the repository at this point in the history
Refactor unnecessary `else` / `elif` when `if` block has a `return` statement
  • Loading branch information
christian-hawk authored Sep 11, 2020
2 parents 9071347 + e3f6d62 commit 7feaf61
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions clientapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from httplib2 import RelativeURIError
from .client_handler import ClientHandler


from .ressources.errors import MismatchingStateError, OAuthError
import os

Expand Down Expand Up @@ -55,7 +54,6 @@
# registra o cliente (app) no op com os dados do discovery
# atualiza client-id, client-secret e metadata-server


# def register_client(op_data: dict, client_url: str) -> dict:
# """[register client and returns client information]

Expand Down Expand Up @@ -97,24 +95,21 @@
# return op_data






def get_preselected_provider():
provider_id_string = cfg.PRE_SELECTED_PROVIDER_ID
print('get_preselected_provider - provider_id_string = %s' % provider_id_string)
print('get_preselected_provider - provider_id_string = %s' %
provider_id_string)
provider_object = '{ "provider" : "%s" }' % provider_id_string
provider_object_bytes = provider_object.encode()
base64url_bytes = base64.urlsafe_b64encode(provider_object_bytes)
base64url_value = base64url_bytes.decode()
print('get_preselected_provider - base64url encoded: %s' % base64url_value)
if base64url_value.endswith('='):
base64url_value_unpad = base64url_value.replace('=','')
print('get_preselected_provider - base64url encoded unpad: %s' % base64url_value_unpad)
base64url_value_unpad = base64url_value.replace('=', '')
print('get_preselected_provider - base64url encoded unpad: %s' %
base64url_value_unpad)
return base64url_value_unpad
else:
return base64url_value
return base64url_value


def ssl_verify(ssl_verify=cfg.SSL_VERIFY):
Expand All @@ -137,13 +132,13 @@ def create_app():
app.config['OP_CLIENT_ID'] = cfg.CLIENT_ID
app.config['OP_CLIENT_SECRET'] = cfg.CLIENT_SECRET
oauth.init_app(app)
oauth.register(
'op',
server_metadata_url=cfg.SERVER_META_URL,
client_kwargs={
'scope': 'openid profile mail user_name',
'acr_value': cfg.ACR_VALUES
}, token_endpoint_auth_method='client_secret_post')
oauth.register('op',
server_metadata_url=cfg.SERVER_META_URL,
client_kwargs={
'scope': 'openid profile mail user_name',
'acr_value': cfg.ACR_VALUES
},
token_endpoint_auth_method='client_secret_post')

# token_endpoint_auth_method = 'client_secret_post')
# client_auth_methods = ['client_secret_post'])
Expand All @@ -164,9 +159,10 @@ def index():

@app.route('/register', methods=['POST'])
def register():
client_handler = ClientHandler('https://t1.techno24x7.com','https://test.com')
client_handler = ClientHandler('https://t1.techno24x7.com',
'https://test.com')
content = request.json
return {},100
return {}, 100

@app.route('/protected-content', methods=['GET'])
def protected_content():
Expand Down Expand Up @@ -235,9 +231,9 @@ def configuration():
if 'provider_id' in content:
cfg.PRE_SELECTED_PROVIDER_ID = content['provider_id']
cfg.PRE_SELECTED_PROVIDER = True
app.logger.debug('/configuration: provider_id = %s' % content['provider_id'])
return jsonify({ "provider_id" : content['provider_id'] }),200

app.logger.debug('/configuration: provider_id = %s' %
content['provider_id'])
return jsonify({"provider_id": content['provider_id']}), 200

else:
return {}, 400
Expand Down

0 comments on commit 7feaf61

Please sign in to comment.