pub struct AuthStore { /* private fields */ }Expand description
Thread-safe in-memory store for authorization data.
Implementations§
Source§impl AuthStore
impl AuthStore
Sourcepub fn create_organization(
&self,
name: String,
display_name: String,
creator: String,
) -> Result<Organization>
pub fn create_organization( &self, name: String, display_name: String, creator: String, ) -> Result<Organization>
Create a new organization.
Sourcepub fn get_organization(&self, id: u64) -> Option<Organization>
pub fn get_organization(&self, id: u64) -> Option<Organization>
Get an organization by ID.
Sourcepub fn get_organization_by_name(&self, name: &str) -> Option<Organization>
pub fn get_organization_by_name(&self, name: &str) -> Option<Organization>
Get an organization by name.
Sourcepub fn list_organizations(&self) -> Vec<Organization>
pub fn list_organizations(&self) -> Vec<Organization>
List all organizations.
Sourcepub fn list_user_organizations(&self, user: &str) -> Vec<Organization>
pub fn list_user_organizations(&self, user: &str) -> Vec<Organization>
List organizations a user belongs to.
Sourcepub fn update_organization(
&self,
id: u64,
display_name: Option<String>,
description: Option<String>,
) -> Result<Organization>
pub fn update_organization( &self, id: u64, display_name: Option<String>, description: Option<String>, ) -> Result<Organization>
Update an organization.
Sourcepub fn delete_organization(&self, id: u64) -> Result<()>
pub fn delete_organization(&self, id: u64) -> Result<()>
Delete an organization.
Sourcepub fn add_org_member(&self, org_id: u64, member: OrgMember) -> Result<()>
pub fn add_org_member(&self, org_id: u64, member: OrgMember) -> Result<()>
Add a member to an organization.
Sourcepub fn remove_org_member(&self, org_id: u64, user: &str) -> Result<()>
pub fn remove_org_member(&self, org_id: u64, user: &str) -> Result<()>
Remove a member from an organization.
Sourcepub fn update_org_member_role(
&self,
org_id: u64,
user: &str,
role: OrgRole,
) -> Result<()>
pub fn update_org_member_role( &self, org_id: u64, user: &str, role: OrgRole, ) -> Result<()>
Update a member’s role in an organization.
Sourcepub fn create_team(
&self,
org_id: u64,
name: String,
permission: Permission,
created_by: String,
) -> Result<Team>
pub fn create_team( &self, org_id: u64, name: String, permission: Permission, created_by: String, ) -> Result<Team>
Create a new team.
Sourcepub fn get_team_by_name(&self, org_id: u64, name: &str) -> Option<Team>
pub fn get_team_by_name(&self, org_id: u64, name: &str) -> Option<Team>
Get a team by org and name.
Sourcepub fn list_teams(&self, org_id: u64) -> Vec<Team>
pub fn list_teams(&self, org_id: u64) -> Vec<Team>
List teams in an organization.
Sourcepub fn list_user_teams(&self, user: &str) -> Vec<Team>
pub fn list_user_teams(&self, user: &str) -> Vec<Team>
List teams a user belongs to.
Sourcepub fn update_team(
&self,
id: u64,
name: Option<String>,
description: Option<String>,
permission: Option<Permission>,
) -> Result<Team>
pub fn update_team( &self, id: u64, name: Option<String>, description: Option<String>, permission: Option<Permission>, ) -> Result<Team>
Update a team.
Sourcepub fn delete_team(&self, id: u64) -> Result<()>
pub fn delete_team(&self, id: u64) -> Result<()>
Delete a team.
Sourcepub fn add_team_member(&self, team_id: u64, user: String) -> Result<()>
pub fn add_team_member(&self, team_id: u64, user: String) -> Result<()>
Add a member to a team.
Sourcepub fn remove_team_member(&self, team_id: u64, user: &str) -> Result<()>
pub fn remove_team_member(&self, team_id: u64, user: &str) -> Result<()>
Remove a member from a team.
Sourcepub fn add_team_repo(&self, team_id: u64, repo_key: String) -> Result<()>
pub fn add_team_repo(&self, team_id: u64, repo_key: String) -> Result<()>
Add a repository to a team.
Sourcepub fn remove_team_repo(&self, team_id: u64, repo_key: &str) -> Result<()>
pub fn remove_team_repo(&self, team_id: u64, repo_key: &str) -> Result<()>
Remove a repository from a team.
Sourcepub fn set_collaborator(
&self,
repo_key: String,
user: String,
permission: Permission,
added_by: String,
) -> Collaborator
pub fn set_collaborator( &self, repo_key: String, user: String, permission: Permission, added_by: String, ) -> Collaborator
Add or update a collaborator.
Sourcepub fn get_collaborator(
&self,
repo_key: &str,
user: &str,
) -> Option<Collaborator>
pub fn get_collaborator( &self, repo_key: &str, user: &str, ) -> Option<Collaborator>
Get a collaborator.
Sourcepub fn list_collaborators(&self, repo_key: &str) -> Vec<Collaborator>
pub fn list_collaborators(&self, repo_key: &str) -> Vec<Collaborator>
List collaborators for a repository.
Sourcepub fn remove_collaborator(&self, repo_key: &str, user: &str) -> Result<()>
pub fn remove_collaborator(&self, repo_key: &str, user: &str) -> Result<()>
Remove a collaborator.
Sourcepub fn set_branch_protection(
&self,
repo_key: String,
pattern: String,
) -> BranchProtection
pub fn set_branch_protection( &self, repo_key: String, pattern: String, ) -> BranchProtection
Set branch protection for a pattern.
Sourcepub fn get_branch_protection(
&self,
repo_key: &str,
pattern: &str,
) -> Option<BranchProtection>
pub fn get_branch_protection( &self, repo_key: &str, pattern: &str, ) -> Option<BranchProtection>
Get branch protection for a pattern.
Sourcepub fn find_branch_protection(
&self,
repo_key: &str,
branch: &str,
) -> Option<BranchProtection>
pub fn find_branch_protection( &self, repo_key: &str, branch: &str, ) -> Option<BranchProtection>
Find branch protection that matches a branch name.
Sourcepub fn list_branch_protections(&self, repo_key: &str) -> Vec<BranchProtection>
pub fn list_branch_protections(&self, repo_key: &str) -> Vec<BranchProtection>
List all branch protections for a repository.
Sourcepub fn update_branch_protection(
&self,
repo_key: &str,
pattern: &str,
update: impl FnOnce(&mut BranchProtection),
) -> Result<BranchProtection>
pub fn update_branch_protection( &self, repo_key: &str, pattern: &str, update: impl FnOnce(&mut BranchProtection), ) -> Result<BranchProtection>
Update branch protection.
Sourcepub fn remove_branch_protection(
&self,
repo_key: &str,
pattern: &str,
) -> Result<()>
pub fn remove_branch_protection( &self, repo_key: &str, pattern: &str, ) -> Result<()>
Remove branch protection.
Sourcepub fn create_webhook(
&self,
repo_key: String,
url: String,
events: HashSet<WebhookEvent>,
) -> Webhook
pub fn create_webhook( &self, repo_key: String, url: String, events: HashSet<WebhookEvent>, ) -> Webhook
Create a webhook.
Sourcepub fn get_webhook(&self, id: u64) -> Option<Webhook>
pub fn get_webhook(&self, id: u64) -> Option<Webhook>
Get a webhook by ID.
Sourcepub fn list_webhooks(&self, repo_key: &str) -> Vec<Webhook>
pub fn list_webhooks(&self, repo_key: &str) -> Vec<Webhook>
List webhooks for a repository.
Sourcepub fn update_webhook(
&self,
id: u64,
update: impl FnOnce(&mut Webhook),
) -> Result<Webhook>
pub fn update_webhook( &self, id: u64, update: impl FnOnce(&mut Webhook), ) -> Result<Webhook>
Update a webhook.
Sourcepub fn delete_webhook(&self, id: u64) -> Result<()>
pub fn delete_webhook(&self, id: u64) -> Result<()>
Delete a webhook.
Sourcepub fn find_webhooks_for_event(
&self,
repo_key: &str,
event: WebhookEvent,
) -> Vec<Webhook>
pub fn find_webhooks_for_event( &self, repo_key: &str, event: WebhookEvent, ) -> Vec<Webhook>
Find webhooks that should fire for an event.
Sourcepub fn check_permission(
&self,
user: &str,
repo_key: &str,
required: Permission,
) -> bool
pub fn check_permission( &self, user: &str, repo_key: &str, required: Permission, ) -> bool
Check if a user has at least the required permission on a repository.
Permission resolution order:
- Repository owner always has Admin
- Direct collaborator permission
- Team permission (highest wins)
- Organization membership (if org owns repo)
Sourcepub fn get_effective_permission(
&self,
user: &str,
repo_key: &str,
) -> Option<Permission>
pub fn get_effective_permission( &self, user: &str, repo_key: &str, ) -> Option<Permission>
Get the effective permission for a user on a repository.