User auth token session display implementation (#1415)

* removed old todo from #62
* implemented proper display for user_auth_token_session
* auth-token-session display fixes
* updated contributors list

---------

Co-authored-by: Firstyear <william@blackhats.net.au>
This commit is contained in:
Sebastiano Tocci 2023-03-07 05:33:51 +01:00 committed by GitHub
parent 5573ab9224
commit 36f1efa559
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View file

@ -25,6 +25,7 @@
- Yuxuan Lu (leoleoasd)
- h7x4
- Pi-Cla
- Sebastiano Tocci(Seba-T)
## Acknowledgements

View file

@ -284,7 +284,6 @@ impl QueryServerReadV1 {
uat: Option<String>,
eventid: Uuid,
) -> Result<WhoamiResponse, OperationError> {
// TODO #62: Move this to IdmServer!!!
// Begin a read
let ct = duration_from_epoch_now();
let mut idms_prox_read = self.idms.proxy_read().await;
@ -301,7 +300,6 @@ impl QueryServerReadV1 {
admin_error!(?e, "Invalid identity");
e
})?;
let srch =
SearchEvent::from_whoami_request(ident, &idms_prox_read.qs_read).map_err(|e| {
admin_error!(?e, "Failed to begin whoami");

View file

@ -8,9 +8,11 @@ use crate::prelude::*;
use std::collections::BTreeSet;
use std::convert::TryFrom;
use std::fmt;
use std::fmt::Formatter;
use std::str::FromStr;
use std::time::Duration;
use crate::valueset::uuid_to_proto_string;
#[cfg(test)]
use base64::{engine::general_purpose, Engine as _};
use compact_jwt::JwsSigner;
@ -766,7 +768,7 @@ impl TryInto<UatPurposeStatus> for SessionScope {
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
pub struct Session {
pub label: String,
pub expiry: Option<OffsetDateTime>,
@ -776,6 +778,25 @@ pub struct Session {
pub scope: SessionScope,
}
impl fmt::Debug for Session {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let issuer = match self.issued_by {
IdentityId::User(u) => format!("User - {}", uuid_to_proto_string(u)),
IdentityId::Synch(u) => format!("Synch - {}", uuid_to_proto_string(u)),
IdentityId::Internal => "Internal".to_string(),
};
let expiry = match self.expiry {
Some(e) => e.to_string(),
None => "never".to_string(),
};
write!(
f,
"expiry: {}, issued at: {}, issued by: {}, credential id: {}, scope: {:?}",
expiry, self.issued_at, issuer, self.cred_id, self.scope
)
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Oauth2Session {
pub parent: Uuid,