Make iss and aud args optional to debug create-jwt command.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-09-09 03:03:53 +00:00
parent adadafa88f
commit de7c5dcbc8

View File

@@ -974,10 +974,10 @@ pub(super) async fn create_jwt(
#[derive(Serialize)] #[derive(Serialize)]
struct Claim { struct Claim {
sub: String, sub: String,
iss: String, iss: Option<String>,
aud: String, aud: Option<String>,
exp: usize, exp: Option<usize>,
nbf: usize, nbf: Option<usize>,
} }
let config = &self.services.config.jwt; let config = &self.services.config.jwt;
@@ -994,21 +994,19 @@ pub(super) async fn create_jwt(
let claim = Claim { let claim = Claim {
sub: user, sub: user,
iss: issuer.unwrap_or_default(), iss: issuer,
aud: audience.unwrap_or_default(), aud: audience,
exp: exp_from_now exp: exp_from_now
.and_then(|val| now_secs().checked_add(val)) .and_then(|val| now_secs().checked_add(val))
.map(TryInto::try_into) .map(TryInto::try_into)
.and_then(Result::ok) .and_then(Result::ok),
.unwrap_or(usize::MAX),
nbf: nbf_from_now nbf: nbf_from_now
.and_then(|val| now_secs().checked_add(val)) .and_then(|val| now_secs().checked_add(val))
.map(TryInto::try_into) .map(TryInto::try_into)
.and_then(Result::ok) .and_then(Result::ok),
.unwrap_or(0),
}; };
encode(&header, &claim, &key) encode(&header, &claim, &key)