mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Cache authenticated session for one time SMS token
This commit is contained in:
parent
d7fcf8a1c9
commit
b063e35c49
|
@ -523,10 +523,20 @@ CLASS lcl_2fa_github_authenticator IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD get_authenticated_client.
|
METHOD get_authenticated_client.
|
||||||
|
STATICS: BEGIN OF ss_cached_client,
|
||||||
|
username TYPE string,
|
||||||
|
client TYPE REF TO if_http_client,
|
||||||
|
END OF ss_cached_client.
|
||||||
DATA: lv_http_code TYPE i,
|
DATA: lv_http_code TYPE i,
|
||||||
lv_http_code_description TYPE string,
|
lv_http_code_description TYPE string,
|
||||||
lo_settings TYPE REF TO lcl_settings.
|
lo_settings TYPE REF TO lcl_settings.
|
||||||
|
|
||||||
|
" If there is a cached client for the same user return it instead
|
||||||
|
IF ss_cached_client-client IS BOUND AND ss_cached_client-username = iv_username.
|
||||||
|
ri_client = ss_cached_client-client.
|
||||||
|
RETURN.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
" Try to login to GitHub API with username, password and 2fa token
|
" Try to login to GitHub API with username, password and 2fa token
|
||||||
|
|
||||||
lo_settings = lcl_app=>settings( )->read( ).
|
lo_settings = lcl_app=>settings( )->read( ).
|
||||||
|
@ -574,6 +584,10 @@ CLASS lcl_2fa_github_authenticator IMPLEMENTATION.
|
||||||
EXPORTING
|
EXPORTING
|
||||||
iv_error_text = |Authentication failed: { lv_http_code_description }|.
|
iv_error_text = |Authentication failed: { lv_http_code_description }|.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
|
" Cache the authenticated http session / client to avoid unnecessary additional authentication
|
||||||
|
ss_cached_client-username = iv_username.
|
||||||
|
ss_cached_client-client = ri_client.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user