-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from stakwork/fix-auth
Fix auth
- Loading branch information
Showing
18 changed files
with
557 additions
and
92 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use rocket::request::{FromRequest, Outcome, Request}; | ||
|
||
#[derive(Debug)] | ||
pub enum SuperAuthError {} | ||
|
||
#[derive(Clone)] | ||
pub struct VerifySuperToken { | ||
pub token: Option<String>, | ||
} | ||
|
||
#[rocket::async_trait] | ||
impl<'r> FromRequest<'r> for VerifySuperToken { | ||
type Error = SuperAuthError; | ||
|
||
async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> { | ||
if let Some(token) = request.headers().get_one("x-super-token") { | ||
return Outcome::Success(VerifySuperToken { | ||
token: Some(token.to_string()), | ||
}); | ||
} else { | ||
Outcome::Success(VerifySuperToken { token: None }) | ||
} | ||
} | ||
} |
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,76 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
#[serde(tag = "type", content = "data")] | ||
pub enum Cmd { | ||
Swarm(SwarmCmd), | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct LoginInfo { | ||
pub username: String, | ||
pub password: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct ChangePasswordInfo { | ||
pub user_id: u32, | ||
pub old_pass: String, | ||
pub password: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct AddNewSwarmInfo { | ||
pub host: String, | ||
pub instance: String, | ||
pub description: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct AddNewSwarmInfoAPI { | ||
pub host: String, | ||
pub instance: String, | ||
pub description: String, | ||
pub username: String, | ||
pub password: String, | ||
pub token: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct UpdateSwarmInfo { | ||
pub id: String, | ||
pub host: String, | ||
pub instance: String, | ||
pub description: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct DeleteSwarmInfo { | ||
pub host: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct ChildSwarm { | ||
pub password: String, | ||
pub host: String, | ||
pub username: String, | ||
pub token: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
#[serde(tag = "cmd", content = "content")] | ||
pub enum SwarmCmd { | ||
GetConfig, | ||
Login(LoginInfo), | ||
ChangePassword(ChangePasswordInfo), | ||
AddNewSwarm(AddNewSwarmInfo), | ||
UpdateSwarm(UpdateSwarmInfo), | ||
DeleteSwarm(DeleteSwarmInfo), | ||
SetChildSwarm(ChildSwarm), | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct AddSwarmResponse { | ||
pub success: bool, | ||
pub message: 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
Oops, something went wrong.