-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for using multiple DID methods (#70)
* feat: add support for multiple DID methods for `Subject` * fix: remove `Subjects` type * feat: add `default_subject_syntax_type` * feat: add `default_subject_syntax_type` getter for `RelyingPartyManager` and `ProviderManager`
- Loading branch information
1 parent
9b3b324
commit a932af7
Showing
31 changed files
with
266 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,11 @@ | ||
use crate::{Collection, Sign, SubjectSyntaxType, Verify}; | ||
use crate::{Sign, Verify}; | ||
use anyhow::Result; | ||
use std::{str::FromStr, sync::Arc}; | ||
use std::sync::Arc; | ||
|
||
pub type SigningSubject = Arc<dyn Subject>; | ||
|
||
// TODO: Use a URI of some sort. | ||
/// This [`Subject`] trait is used to sign and verify JWTs. | ||
pub trait Subject: Sign + Verify + Send + Sync { | ||
fn identifier(&self) -> Result<String>; | ||
fn type_(&self) -> Result<SubjectSyntaxType> { | ||
SubjectSyntaxType::from_str(&self.identifier()?) | ||
} | ||
} | ||
|
||
pub type Subjects = Collection<dyn Subject>; | ||
|
||
impl Subjects { | ||
pub fn get_subject(&self, subject_syntax_type: SubjectSyntaxType) -> Option<Arc<dyn Subject>> { | ||
self.iter() | ||
.find(|&subject| *subject.0 == subject_syntax_type) | ||
.map(|subject| subject.1.clone()) | ||
} | ||
} | ||
|
||
impl<const N: usize> TryFrom<[Arc<dyn Subject>; N]> for Subjects { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(subjects: [Arc<dyn Subject>; N]) -> Result<Self> { | ||
Ok(Self::from( | ||
subjects | ||
.iter() | ||
.map(|subject| subject.type_().map(|subject_type| (subject_type, subject.clone()))) | ||
.collect::<Result<Vec<_>>>()?, | ||
)) | ||
} | ||
fn identifier(&self, subject_syntax_type: &str) -> Result<String>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.