Skip to content
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

SAP ID SSO: Gigya SDK build number is retrieved multiple times, not cached #22

Open
fnschmidt opened this issue May 6, 2024 · 1 comment

Comments

@fnschmidt
Copy link

Inside sap_id_sso.py is the following code:

def _get_sdk_build_number(api_key):
global GIGYA_SDK_BUILD_NUMBER
if GIGYA_SDK_BUILD_NUMBER is not None:
return GIGYA_SDK_BUILD_NUMBER

This seems to imply caching, however GIGYA_SDK_BUILD_NUMBER is never assigned to and always remains None.
Is there a reason for this? The only argument in that function is the API key, but as of now, for all three invocations it is the same.

Considering the gigya.js is over 500 KB in size and the regex takes fairly long, caching would make sense.
Perhaps that was the plan all along, but assigning to the global was forgotten?

@sean-freeman
Copy link
Member

sean-freeman commented Jun 21, 2024

You are correct, Py Func _get_sdk_build_number performs a request to the endpoint to get the current Gigya SDK Build Number. This function is called only by 1 Py Func _cdc_api_request, but that Py Func is itself called 3 times in the sequence as shown below:

_get_gigya_login_token > _cdc_api_request > _get_sdk_build_number
_get_uid > _cdc_api_request > _get_sdk_build_number
_get_id_token > _cdc_api_request > _get_sdk_build_number

The Py Func _get_gigya_login_token is called first, so could set the global var pretty easily by appending 1 line before the final return, subsequent calls to the Py Func would then be caught by the existing if logic if GIGYA_SDK_BUILD_NUMBER is not None.

def _get_sdk_build_number(api_key):
    global GIGYA_SDK_BUILD_NUMBER
    if GIGYA_SDK_BUILD_NUMBER is not None:
        return GIGYA_SDK_BUILD_NUMBER
...
...
    GIGYA_SDK_BUILD_NUMBER = build_number    # line to append
    return build_number

I'll try to look at testing this in future, it is very low on my todo backlog though so feel free to use above analysis and confirm, then a PR can be created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants