Access token permissions
This commit is contained in:
@@ -83,8 +83,6 @@ pub struct JmapConfig {
|
||||
pub encrypt: bool,
|
||||
pub encrypt_append: bool,
|
||||
|
||||
pub principal_allow_lookups: bool,
|
||||
|
||||
pub capabilities: BaseCapabilities,
|
||||
pub session_purge_frequency: SimpleCron,
|
||||
pub account_purge_frequency: SimpleCron,
|
||||
@@ -371,9 +369,6 @@ impl JmapConfig {
|
||||
push_max_total: config
|
||||
.property_or_default("jmap.push.max-total", "100")
|
||||
.unwrap_or(100),
|
||||
principal_allow_lookups: config
|
||||
.property("jmap.principal.allow-lookups")
|
||||
.unwrap_or(true),
|
||||
encrypt: config
|
||||
.property_or_default("storage.encryption.enable", "true")
|
||||
.unwrap_or(true),
|
||||
|
||||
@@ -19,7 +19,7 @@ use config::{
|
||||
storage::Storage,
|
||||
telemetry::Metrics,
|
||||
};
|
||||
use directory::{core::secret::verify_secret_hash, Directory, Principal, QueryBy, Type};
|
||||
use directory::{core::secret::verify_secret_hash, Directory, Principal, QueryBy};
|
||||
use expr::if_block::IfBlock;
|
||||
use listener::{
|
||||
blocked::{AllowedIps, BlockedIps},
|
||||
@@ -227,7 +227,7 @@ impl Core {
|
||||
credentials: &Credentials<String>,
|
||||
remote_ip: IpAddr,
|
||||
return_member_of: bool,
|
||||
) -> trc::Result<Principal<u32>> {
|
||||
) -> trc::Result<Principal> {
|
||||
// First try to authenticate the user against the default directory
|
||||
let result = match directory
|
||||
.query(QueryBy::Credentials(credentials), return_member_of)
|
||||
@@ -237,9 +237,9 @@ impl Core {
|
||||
trc::event!(
|
||||
Auth(trc::AuthEvent::Success),
|
||||
AccountName = credentials.login().to_string(),
|
||||
AccountId = principal.id,
|
||||
AccountId = principal.id(),
|
||||
SpanId = session_id,
|
||||
Type = principal.typ.as_str(),
|
||||
Type = principal.typ().as_str(),
|
||||
);
|
||||
|
||||
return Ok(principal);
|
||||
@@ -268,7 +268,6 @@ impl Core {
|
||||
Auth(trc::AuthEvent::Success),
|
||||
AccountName = username.clone(),
|
||||
SpanId = session_id,
|
||||
Type = Type::Superuser.as_str(),
|
||||
);
|
||||
|
||||
return Ok(Principal::fallback_admin(fallback_pass));
|
||||
@@ -289,8 +288,8 @@ impl Core {
|
||||
Auth(trc::AuthEvent::Success),
|
||||
AccountName = username.to_string(),
|
||||
SpanId = session_id,
|
||||
AccountId = principal.id,
|
||||
Type = principal.typ.as_str(),
|
||||
AccountId = principal.id(),
|
||||
Type = principal.typ().as_str(),
|
||||
);
|
||||
|
||||
return Ok(principal);
|
||||
|
||||
@@ -23,7 +23,11 @@ pub(crate) fn sign(
|
||||
let combined = format!("{}.{}", &protected, &payload);
|
||||
let signature = key
|
||||
.sign(&SystemRandom::new(), combined.as_bytes())
|
||||
.map_err(|err| trc::EventType::Acme(trc::AcmeEvent::Error).caused_by(trc::location!()).reason(err))?;
|
||||
.map_err(|err| {
|
||||
trc::EventType::Acme(trc::AcmeEvent::Error)
|
||||
.caused_by(trc::location!())
|
||||
.reason(err)
|
||||
})?;
|
||||
let signature = URL_SAFE_NO_PAD.encode(signature.as_ref());
|
||||
let body = Body {
|
||||
protected,
|
||||
@@ -31,7 +35,8 @@ pub(crate) fn sign(
|
||||
signature,
|
||||
};
|
||||
|
||||
serde_json::to_string(&body).map_err(|err| trc::EventType::Acme(trc::AcmeEvent::Error).from_json_error(err))
|
||||
serde_json::to_string(&body)
|
||||
.map_err(|err| trc::EventType::Acme(trc::AcmeEvent::Error).from_json_error(err))
|
||||
}
|
||||
|
||||
pub(crate) fn key_authorization(key: &EcdsaKeyPair, token: &str) -> trc::Result<String> {
|
||||
|
||||
Reference in New Issue
Block a user