Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions container-stack/svalinn/src/auth/AuthTypes.affine
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ pub struct UserContext {
}

fn perm(resource: String, actions: [PermissionAction]) -> Permission {
Permission { resource: resource, actions: actions }
Permission #{ resource: resource, actions: actions }
}

// Default RBAC roles (== AuthTypes.res defaultRoles).
pub fn default_roles() -> [Role] {
[
Role {
Role #{
name: "admin",
description: Some("Full access to all resources"),
permissions: [perm("*", [Create, Read, Update, Delete, Execute])]
},
Role {
Role #{
name: "operator",
description: Some("Can manage containers but not policies"),
permissions: [
Expand All @@ -136,7 +136,7 @@ pub fn default_roles() -> [Role] {
perm("policies", [Read])
]
},
Role {
Role #{
name: "viewer",
description: Some("Read-only access"),
permissions: [
Expand All @@ -145,7 +145,7 @@ pub fn default_roles() -> [Role] {
perm("policies", [Read])
]
},
Role {
Role #{
name: "auditor",
description: Some("Can view logs and audit trail"),
permissions: [
Expand Down
8 changes: 4 additions & 4 deletions container-stack/svalinn/src/gateway/RateLimiter.affine
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Config {
}

pub fn default_config() -> Config {
Config { window_ms: 60000, max_requests: 100 }
Config #{ window_ms: 60000, max_requests: 100 }
}

// Outcome of a check. `count`/`window_start` are the values the host must
Expand All @@ -36,7 +36,7 @@ fn ceil_div(a: Int, b: Int) -> Int {
pub fn check(cfg: Config, count: Int, window_start: Int, now_ms: Int) -> Decision {
// New client, or expired window → start a fresh window.
if window_start == 0 || now_ms - window_start > cfg.window_ms {
return Decision {
return Decision #{
allowed: true,
count: 1,
window_start: now_ms,
Expand All @@ -48,7 +48,7 @@ pub fn check(cfg: Config, count: Int, window_start: Int, now_ms: Int) -> Decisio
if count < cfg.max_requests {
let new_count = count + 1;
let rem = cfg.max_requests - new_count;
return Decision {
return Decision #{
allowed: true,
count: new_count,
window_start: window_start,
Expand All @@ -60,7 +60,7 @@ pub fn check(cfg: Config, count: Int, window_start: Int, now_ms: Int) -> Decisio
// Limited.
let reset_at = window_start + cfg.window_ms;
let ms_left = reset_at - now_ms;
Decision {
Decision #{
allowed: false,
count: count,
window_start: window_start,
Expand Down
Loading