Skip to content

Commit

Permalink
Merge branch 'tim/new_verif_method_oidc' into 'master'
Browse files Browse the repository at this point in the history
feat: Upgrade verif method with new OIDC provider fields (BREAKING)

See merge request TankerHQ/sdk-python!296
  • Loading branch information
tux3 committed Sep 19, 2023
2 parents 60153b4 + e4398a0 commit eea6e94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cffi_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ struct tanker_verification_method
// enum cannot be binded to java as they do not have a fixed size.
// It takes a value from tanker_verification_method_type:
uint8_t verification_method_type;
char const* value;
char const* value1;
char const* value2;
};

struct tanker_verification_options
Expand Down
19 changes: 14 additions & 5 deletions tankersdk/tanker.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def __init__(self, phone_number: str):
class OidcIdTokenVerificationMethod(VerificationMethod):
method_type = VerificationMethodType.OIDC_ID_TOKEN

def __init__(self, provider_id: str, provider_display_name: str):
self.provider_id = provider_id
self.provider_display_name = provider_display_name


class PassphraseVerificationMethod(VerificationMethod):
method_type = VerificationMethodType.PASSPHRASE
Expand Down Expand Up @@ -194,24 +198,29 @@ def verification_method_from_c(c_verification_method: CData) -> VerificationMeth
method_type = VerificationMethodType(c_verification_method.verification_method_type)
res: Optional[VerificationMethod] = None
if method_type == VerificationMethodType.EMAIL:
c_email = c_verification_method.value
c_email = c_verification_method.value1
res = EmailVerificationMethod(ffihelpers.c_string_to_str(c_email))
elif method_type == VerificationMethodType.PASSPHRASE:
res = PassphraseVerificationMethod()
elif method_type == VerificationMethodType.VERIFICATION_KEY:
res = VerificationKeyVerificationMethod()
elif method_type == VerificationMethodType.OIDC_ID_TOKEN:
res = OidcIdTokenVerificationMethod()
c_provider_id = c_verification_method.value1
c_provider_display_name = c_verification_method.value2
res = OidcIdTokenVerificationMethod(
ffihelpers.c_string_to_str(c_provider_id),
ffihelpers.c_string_to_str(c_provider_display_name),
)
elif method_type == VerificationMethodType.PHONE_NUMBER:
c_phone_number = c_verification_method.value
c_phone_number = c_verification_method.value1
res = PhoneNumberVerificationMethod(ffihelpers.c_string_to_str(c_phone_number))
elif method_type == VerificationMethodType.PREVERIFIED_EMAIL:
c_preverified_email = c_verification_method.value
c_preverified_email = c_verification_method.value1
res = PreverifiedEmailVerificationMethod(
ffihelpers.c_string_to_str(c_preverified_email)
)
elif method_type == VerificationMethodType.PREVERIFIED_PHONE_NUMBER:
c_preverified_phone_number = c_verification_method.value
c_preverified_phone_number = c_verification_method.value1
res = PreverifiedPhoneNumberVerificationMethod(
ffihelpers.c_string_to_str(c_preverified_phone_number)
)
Expand Down

0 comments on commit eea6e94

Please sign in to comment.