Skip to content

Commit

Permalink
Merge branch 'quentin/deprecateOldOidcFlow' into 'master'
Browse files Browse the repository at this point in the history
chore(core): deprecate old OIDC flow

See merge request TankerHQ/sdk-rust!183
  • Loading branch information
quentinvernot committed Jun 12, 2024
2 parents f8528b6 + f2d5c8a commit aeec285
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,19 @@ impl Core {
}

/// Creates a nonce to use during Oidc authorization code flow
#[deprecated(
since = "4.2.0",
note = "The entire OIDC flow has been reworked, this function has been deprecated as a result"
)]
pub async fn create_oidc_nonce(&self) -> Result<String, Error> {
unsafe { CTankerLib::get().create_oidc_nonce(self.ctanker).await }
}

/// Set the nonce to use for Oidc verification
#[deprecated(
since = "4.2.0",
note = "The entire OIDC flow has been reworked, this function has been deprecated as a result"
)]
pub async fn set_oidc_test_nonce(&self, nonce: &str) -> Result<(), Error> {
unsafe {
CTankerLib::get()
Expand Down
5 changes: 5 additions & 0 deletions src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ pub enum Verification {
Passphrase(String),
VerificationKey(String),
#[allow(clippy::upper_case_acronyms)]
#[deprecated(
since = "4.2.0",
note = "The entire OIDC flow has been reworked, this verification method has been deprecated as a result, use Verification::OIDCAuthorizationCode instead"
)]
OIDCIDToken(String),
PhoneNumber {
phone_number: String,
Expand Down Expand Up @@ -249,6 +253,7 @@ impl Verification {
CVerificationWrapper::with_passphrase(passphrase)
}
Verification::VerificationKey(key) => CVerificationWrapper::with_verification_key(key),
#[allow(deprecated)]
Verification::OIDCIDToken(token) => CVerificationWrapper::with_oidc_id_token(token),
Verification::PhoneNumber {
phone_number,
Expand Down
13 changes: 13 additions & 0 deletions tests/verify_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,22 @@ async fn unlock_with_oidc_id_token() -> Result<(), Box<dyn std::error::Error>> {

let tanker = Core::new(app.make_options()).await?;
tanker.start(&martine_identity).await?;
#[allow(deprecated)]
let verif = Verification::OIDCIDToken(oidc_token);

#[allow(deprecated)]
let nonce = tanker.create_oidc_nonce().await?;
#[allow(deprecated)]
tanker.set_oidc_test_nonce(&nonce).await?;
tanker
.register_identity(&verif, &VerificationOptions::new())
.await?;
tanker.stop().await?;

let tanker = Core::new(app.make_options()).await?;
#[allow(deprecated)]
let nonce = tanker.create_oidc_nonce().await?;
#[allow(deprecated)]
tanker.set_oidc_test_nonce(&nonce).await?;
tanker.start(&martine_identity).await?;
assert_eq!(tanker.status(), Status::IdentityVerificationNeeded);
Expand Down Expand Up @@ -553,9 +558,12 @@ async fn verify_identity_fail_with_preverified_oidc() -> Result<(), Box<dyn std:

let tanker = Core::new(app.make_options()).await?;
assert_eq!(tanker.start(id).await?, Status::IdentityRegistrationNeeded);
#[allow(deprecated)]
let nonce = tanker.create_oidc_nonce().await?;
#[allow(deprecated)]
tanker.set_oidc_test_nonce(&nonce).await?;

#[allow(deprecated)]
let verif = Verification::OIDCIDToken(id_token);
tanker
.register_identity(&verif, &VerificationOptions::new())
Expand Down Expand Up @@ -718,6 +726,7 @@ async fn set_verification_method_with_preverified_oidc() -> Result<(), Box<dyn s
*methods,
[
VerificationMethod::Passphrase,
#[allow(deprecated)]
VerificationMethod::OIDCIDToken {
provider_id: oidc_provider.id,
provider_display_name: oidc_provider.display_name
Expand All @@ -729,8 +738,11 @@ async fn set_verification_method_with_preverified_oidc() -> Result<(), Box<dyn s

let tanker = Core::new(app.make_options()).await?;
tanker.start(id).await?;
#[allow(deprecated)]
let nonce = tanker.create_oidc_nonce().await?;
#[allow(deprecated)]
tanker.set_oidc_test_nonce(&nonce).await?;
#[allow(deprecated)]
let verif = Verification::OIDCIDToken(id_token);
tanker
.verify_identity(&verif, &VerificationOptions::new())
Expand Down Expand Up @@ -774,6 +786,7 @@ async fn set_verification_method_with_oidc_authorization_code(
methods,
&[
VerificationMethod::Passphrase,
#[allow(deprecated)]
VerificationMethod::OIDCIDToken {
provider_id: oidc_provider.id.clone(),
provider_display_name: oidc_provider.display_name
Expand Down

0 comments on commit aeec285

Please sign in to comment.