-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auth: auth-server: Define key management API
- Loading branch information
Showing
21 changed files
with
396 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "auth-server-api" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ["derive"] } | ||
uuid = "1.0" |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! API types for the auth server | ||
|
||
#![deny(missing_docs)] | ||
#![deny(clippy::missing_docs_in_private_items)] | ||
#![deny(unsafe_code)] | ||
#![deny(clippy::needless_pass_by_ref_mut)] | ||
#![feature(trivial_bounds)] | ||
|
||
use serde::Deserialize; | ||
use uuid::Uuid; | ||
|
||
// ---------------------- | ||
// | API Key Management | | ||
// ---------------------- | ||
|
||
/// The path to create a new API key | ||
/// | ||
/// POST /api-keys | ||
pub const API_KEYS_PATH: &str = "api-keys"; | ||
/// The path to mark an API key as inactive | ||
/// | ||
/// POST /api-keys/{id}/deactivate | ||
pub const DEACTIVATE_API_KEY_PATH: &str = "deactivate"; | ||
|
||
/// A request to create a new API key | ||
#[derive(Debug, Deserialize)] | ||
pub struct CreateApiKeyRequest { | ||
/// The API key id | ||
pub id: Uuid, | ||
/// The API key secret | ||
/// | ||
/// Expected as a base64 encoded string | ||
pub secret: String, | ||
/// The name of the API key | ||
pub name: String, | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Error types for the auth server | ||
|
||
use thiserror::Error; | ||
|
||
/// Custom error type for server errors | ||
#[derive(Error, Debug)] | ||
pub enum AuthServerError { | ||
/// Database connection error | ||
#[error("Database connection error: {0}")] | ||
DatabaseConnection(String), | ||
|
||
/// Encryption error | ||
#[error("Encryption error: {0}")] | ||
Encryption(String), | ||
|
||
/// Decryption error | ||
#[error("Decryption error: {0}")] | ||
Decryption(String), | ||
} | ||
|
||
impl AuthServerError { | ||
/// Create a new database connection error | ||
pub fn db<T: ToString>(msg: T) -> Self { | ||
Check failure on line 23 in auth/auth-server/src/error.rs GitHub Actions / clippythis argument is passed by value, but not consumed in the function body
|
||
Self::DatabaseConnection(msg.to_string()) | ||
} | ||
|
||
/// Create a new encryption error | ||
pub fn encryption<T: ToString>(msg: T) -> Self { | ||
Check failure on line 28 in auth/auth-server/src/error.rs GitHub Actions / clippythis argument is passed by value, but not consumed in the function body
|
||
Self::Encryption(msg.to_string()) | ||
} | ||
|
||
/// Create a new decryption error | ||
pub fn decryption<T: ToString>(msg: T) -> Self { | ||
Check failure on line 33 in auth/auth-server/src/error.rs GitHub Actions / clippythis argument is passed by value, but not consumed in the function body
|
||
Self::Decryption(msg.to_string()) | ||
} | ||
} | ||
|
||
impl warp::reject::Reject for AuthServerError {} |
Oops, something went wrong.