-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f097892
commit 7f4eeb6
Showing
45 changed files
with
1,837 additions
and
237 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,50 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use derive_more::derive::From; | ||
use nr_macros::Scopes; | ||
use serde::Serialize; | ||
use sqlx::prelude::Type; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Type, Serialize, Deserialize)] | ||
use strum::EnumIter; | ||
use thiserror::Error; | ||
use utoipa::ToSchema; | ||
#[derive(Debug, Error, From)] | ||
#[error("Invalid Scope: {0}")] | ||
pub struct InvalidScope(pub String); | ||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Type, ToSchema, EnumIter, Scopes)] | ||
#[sqlx(type_name = "TEXT")] | ||
pub enum Scopes { | ||
pub enum NRScope { | ||
/// Can read all repositories the user has access to | ||
#[scope(title = "Read Repository", parent = "Repository")] | ||
ReadRepository, | ||
/// Can write to all repositories the user has access to | ||
#[scope(title = "Write Repository", parent = "Repository")] | ||
WriteRepository, | ||
/// Can edit all repositories the user has access to | ||
#[scope(title = "Edit Repository", parent = "Repository")] | ||
EditRepository, | ||
#[scope(title = "Update Repository", parent = "User")] | ||
/// Update your password | ||
UpdatePassword, | ||
} | ||
#[derive(Debug, Serialize, PartialEq, Eq, Hash, ToSchema)] | ||
pub struct ScopeDescription { | ||
pub key: NRScope, | ||
pub description: &'static str, | ||
pub name: &'static str, | ||
pub parent: Option<&'static str>, | ||
pub requires_user_manager: bool, | ||
pub requires_admin: bool, | ||
pub requires_system: bool, | ||
} | ||
|
||
impl Default for ScopeDescription { | ||
fn default() -> Self { | ||
Self { | ||
key: NRScope::ReadRepository, | ||
description: "", | ||
name: "", | ||
parent: None, | ||
requires_user_manager: false, | ||
requires_admin: false, | ||
requires_system: false, | ||
} | ||
} | ||
} |
Oops, something went wrong.