AuthStore

Struct AuthStore 

Source
pub struct AuthStore { /* private fields */ }
Expand description

Thread-safe in-memory store for authorization data.

Implementations§

Source§

impl AuthStore

Source

pub fn new() -> Self

Create a new empty auth store.

Source

pub fn create_organization( &self, name: String, display_name: String, creator: String, ) -> Result<Organization>

Create a new organization.

Source

pub fn get_organization(&self, id: u64) -> Option<Organization>

Get an organization by ID.

Source

pub fn get_organization_by_name(&self, name: &str) -> Option<Organization>

Get an organization by name.

Source

pub fn list_organizations(&self) -> Vec<Organization>

List all organizations.

Source

pub fn list_user_organizations(&self, user: &str) -> Vec<Organization>

List organizations a user belongs to.

Source

pub fn update_organization( &self, id: u64, display_name: Option<String>, description: Option<String>, ) -> Result<Organization>

Update an organization.

Source

pub fn delete_organization(&self, id: u64) -> Result<()>

Delete an organization.

Source

pub fn add_org_member(&self, org_id: u64, member: OrgMember) -> Result<()>

Add a member to an organization.

Source

pub fn remove_org_member(&self, org_id: u64, user: &str) -> Result<()>

Remove a member from an organization.

Source

pub fn update_org_member_role( &self, org_id: u64, user: &str, role: OrgRole, ) -> Result<()>

Update a member’s role in an organization.

Source

pub fn create_team( &self, org_id: u64, name: String, permission: Permission, created_by: String, ) -> Result<Team>

Create a new team.

Source

pub fn get_team(&self, id: u64) -> Option<Team>

Get a team by ID.

Source

pub fn get_team_by_name(&self, org_id: u64, name: &str) -> Option<Team>

Get a team by org and name.

Source

pub fn list_teams(&self, org_id: u64) -> Vec<Team>

List teams in an organization.

Source

pub fn list_user_teams(&self, user: &str) -> Vec<Team>

List teams a user belongs to.

Source

pub fn update_team( &self, id: u64, name: Option<String>, description: Option<String>, permission: Option<Permission>, ) -> Result<Team>

Update a team.

Source

pub fn delete_team(&self, id: u64) -> Result<()>

Delete a team.

Source

pub fn add_team_member(&self, team_id: u64, user: String) -> Result<()>

Add a member to a team.

Source

pub fn remove_team_member(&self, team_id: u64, user: &str) -> Result<()>

Remove a member from a team.

Source

pub fn add_team_repo(&self, team_id: u64, repo_key: String) -> Result<()>

Add a repository to a team.

Source

pub fn remove_team_repo(&self, team_id: u64, repo_key: &str) -> Result<()>

Remove a repository from a team.

Source

pub fn set_collaborator( &self, repo_key: String, user: String, permission: Permission, added_by: String, ) -> Collaborator

Add or update a collaborator.

Source

pub fn get_collaborator( &self, repo_key: &str, user: &str, ) -> Option<Collaborator>

Get a collaborator.

Source

pub fn list_collaborators(&self, repo_key: &str) -> Vec<Collaborator>

List collaborators for a repository.

Source

pub fn remove_collaborator(&self, repo_key: &str, user: &str) -> Result<()>

Remove a collaborator.

Source

pub fn set_branch_protection( &self, repo_key: String, pattern: String, ) -> BranchProtection

Set branch protection for a pattern.

Source

pub fn get_branch_protection( &self, repo_key: &str, pattern: &str, ) -> Option<BranchProtection>

Get branch protection for a pattern.

Source

pub fn find_branch_protection( &self, repo_key: &str, branch: &str, ) -> Option<BranchProtection>

Find branch protection that matches a branch name.

Source

pub fn list_branch_protections(&self, repo_key: &str) -> Vec<BranchProtection>

List all branch protections for a repository.

Source

pub fn update_branch_protection( &self, repo_key: &str, pattern: &str, update: impl FnOnce(&mut BranchProtection), ) -> Result<BranchProtection>

Update branch protection.

Source

pub fn remove_branch_protection( &self, repo_key: &str, pattern: &str, ) -> Result<()>

Remove branch protection.

Source

pub fn create_webhook( &self, repo_key: String, url: String, events: HashSet<WebhookEvent>, ) -> Webhook

Create a webhook.

Source

pub fn get_webhook(&self, id: u64) -> Option<Webhook>

Get a webhook by ID.

Source

pub fn list_webhooks(&self, repo_key: &str) -> Vec<Webhook>

List webhooks for a repository.

Source

pub fn update_webhook( &self, id: u64, update: impl FnOnce(&mut Webhook), ) -> Result<Webhook>

Update a webhook.

Source

pub fn delete_webhook(&self, id: u64) -> Result<()>

Delete a webhook.

Source

pub fn find_webhooks_for_event( &self, repo_key: &str, event: WebhookEvent, ) -> Vec<Webhook>

Find webhooks that should fire for an event.

Source

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:

  1. Repository owner always has Admin
  2. Direct collaborator permission
  3. Team permission (highest wins)
  4. Organization membership (if org owns repo)
Source

pub fn get_effective_permission( &self, user: &str, repo_key: &str, ) -> Option<Permission>

Get the effective permission for a user on a repository.

Trait Implementations§

Source§

impl Debug for AuthStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AuthStore

Source§

fn default() -> AuthStore

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.