-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
||
if 'id_token' in response_json: | ||
if response_json['id_token'] is not None: | ||
is_valid = validate_id_token(response_json['id_token'], obj.client_id, obj.issuer_uri, obj.jwks_uri) | ||
if is_valid: | ||
obj.id_token = response_json['id_token'] | ||
|
||
if 'id_token' in response_json and response_json['id_token'] is not None: | ||
if is_valid := validate_id_token( | ||
response_json['id_token'], | ||
obj.client_id, | ||
obj.issuer_uri, | ||
obj.jwks_uri, | ||
): | ||
obj.id_token = response_json['id_token'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function set_attributes
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
) - Use named expression to simplify assignment and conditional (
use-named-expression
)
return ''.join(random.choice(allowed_chars) for i in range(length)) | ||
return ''.join(random.choice(allowed_chars) for _ in range(length)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function generate_token
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
if id_token_payload['iss'] != intuit_issuer: | ||
if ( | ||
id_token_payload['iss'] != intuit_issuer | ||
or id_token_payload['aud'][0] != client_id | ||
): | ||
return False | ||
elif id_token_payload['aud'][0] != client_id: | ||
return False | ||
|
||
current_time = (datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() | ||
if id_token_payload['exp'] < current_time: | ||
return False | ||
|
||
message = id_token_parts[0] + '.' + id_token_parts[1] | ||
message = f'{id_token_parts[0]}.{id_token_parts[1]}' | ||
keys_dict = get_jwk(id_token_header['kid'], jwk_uri) | ||
|
||
public_key = jwk.construct(keys_dict) | ||
is_signature_valid = public_key.verify(message.encode('utf-8'), id_token_signature) | ||
return is_signature_valid | ||
return public_key.verify(message.encode('utf-8'), id_token_signature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function validate_id_token
refactored with the following changes:
- Merge duplicate blocks in conditional (
merge-duplicate-blocks
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Remove redundant conditional (
remove-redundant-if
)
keys = next(key for key in data["keys"] if key['kid'] == kid) | ||
return keys | ||
return next(key for key in data["keys"] if key['kid'] == kid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_jwk
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.59%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!