Jazz Turner-Baggs a610117e81
Update Context to accept External Identity Provider. (#127)
* rename .account_id() to .id()

* Create logos-traits crate

* Remove AccountId references

* external IdentityProvider for Context

* Fix compile errors from merge

* Update logos-traits to shared-traits

* format fixes

* warnings cleanup

* clippy fix

* Remove rebase artifact
2026-06-10 06:59:04 -07:00

40 lines
1.0 KiB
Rust

use crypto::{Ed25519Signature, Ed25519VerifyingKey};
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct IdentId(String);
pub type IdentIdRef<'a> = &'a IdentId;
impl IdentId {
pub fn new(id: impl Into<String>) -> Self {
Self(id.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl fmt::Display for IdentId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
impl AsRef<str> for IdentId {
fn as_ref(&self) -> &str {
&self.0
}
}
/// Represents an external Identity
/// Implement this to provide an Authentication model for users/installations
pub trait IdentityProvider {
fn id(&self) -> IdentIdRef<'_>;
// Display name is not garenteed to be consistent. It should only be used to
// provded a more readable identifier for the account.
fn display_name(&self) -> String;
fn sign(&self, payload: &[u8]) -> Ed25519Signature;
fn public_key(&self) -> &Ed25519VerifyingKey;
}