Skip to content

Commit eea6e94

Browse files
committed
Merge branch 'tim/new_verif_method_oidc' into 'master'
feat: Upgrade verif method with new OIDC provider fields (BREAKING) See merge request TankerHQ/sdk-python!296
2 parents 60153b4 + e4398a0 commit eea6e94

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

cffi_defs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ struct tanker_verification_method
321321
// enum cannot be binded to java as they do not have a fixed size.
322322
// It takes a value from tanker_verification_method_type:
323323
uint8_t verification_method_type;
324-
char const* value;
324+
char const* value1;
325+
char const* value2;
325326
};
326327

327328
struct tanker_verification_options

tankersdk/tanker.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ def __init__(self, phone_number: str):
163163
class OidcIdTokenVerificationMethod(VerificationMethod):
164164
method_type = VerificationMethodType.OIDC_ID_TOKEN
165165

166+
def __init__(self, provider_id: str, provider_display_name: str):
167+
self.provider_id = provider_id
168+
self.provider_display_name = provider_display_name
169+
166170

167171
class PassphraseVerificationMethod(VerificationMethod):
168172
method_type = VerificationMethodType.PASSPHRASE
@@ -194,24 +198,29 @@ def verification_method_from_c(c_verification_method: CData) -> VerificationMeth
194198
method_type = VerificationMethodType(c_verification_method.verification_method_type)
195199
res: Optional[VerificationMethod] = None
196200
if method_type == VerificationMethodType.EMAIL:
197-
c_email = c_verification_method.value
201+
c_email = c_verification_method.value1
198202
res = EmailVerificationMethod(ffihelpers.c_string_to_str(c_email))
199203
elif method_type == VerificationMethodType.PASSPHRASE:
200204
res = PassphraseVerificationMethod()
201205
elif method_type == VerificationMethodType.VERIFICATION_KEY:
202206
res = VerificationKeyVerificationMethod()
203207
elif method_type == VerificationMethodType.OIDC_ID_TOKEN:
204-
res = OidcIdTokenVerificationMethod()
208+
c_provider_id = c_verification_method.value1
209+
c_provider_display_name = c_verification_method.value2
210+
res = OidcIdTokenVerificationMethod(
211+
ffihelpers.c_string_to_str(c_provider_id),
212+
ffihelpers.c_string_to_str(c_provider_display_name),
213+
)
205214
elif method_type == VerificationMethodType.PHONE_NUMBER:
206-
c_phone_number = c_verification_method.value
215+
c_phone_number = c_verification_method.value1
207216
res = PhoneNumberVerificationMethod(ffihelpers.c_string_to_str(c_phone_number))
208217
elif method_type == VerificationMethodType.PREVERIFIED_EMAIL:
209-
c_preverified_email = c_verification_method.value
218+
c_preverified_email = c_verification_method.value1
210219
res = PreverifiedEmailVerificationMethod(
211220
ffihelpers.c_string_to_str(c_preverified_email)
212221
)
213222
elif method_type == VerificationMethodType.PREVERIFIED_PHONE_NUMBER:
214-
c_preverified_phone_number = c_verification_method.value
223+
c_preverified_phone_number = c_verification_method.value1
215224
res = PreverifiedPhoneNumberVerificationMethod(
216225
ffihelpers.c_string_to_str(c_preverified_phone_number)
217226
)

0 commit comments

Comments
 (0)