Skip to content

Commit

Permalink
Merge branch 'restructure/0.3.0' of github.com:junkurihara/doh-auth-p…
Browse files Browse the repository at this point in the history
…roxy into restructure/0.3.0
  • Loading branch information
junkurihara committed Oct 23, 2023
2 parents 858190c + 410afd0 commit 856aef2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 32 deletions.
33 changes: 4 additions & 29 deletions dap-lib/src/auth/auth.rs → dap-lib/src/auth/authenticator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use super::token::{Algorithm, TokenInner, TokenMeta, VerificationKeyType};
use super::{
message::{AuthenticationReqInner, AuthenticationRequest, AuthenticationResponse, JwksResponse},
token::{Algorithm, TokenInner, VerificationKeyType},
};
use crate::{
constants::{ENDPOINT_JWKS_PATH, ENDPOINT_LOGIN_PATH},
error::*,
Expand All @@ -9,37 +12,9 @@ use crate::{
use jwt_compact::alg::Es256;
use jwt_simple::prelude::{ES256PublicKey, JWTClaims, NoCustomClaims};
use p256::elliptic_curve::sec1::ToEncodedPoint;
use serde::{Deserialize, Serialize};
use std::{str::FromStr, sync::Arc};
use tokio::sync::RwLock;

/// Authentication request
#[derive(Serialize)]
pub struct AuthenticationRequest {
auth: AuthenticationReqInner,
client_id: String,
}
#[derive(Serialize)]
/// Auth req inner
pub struct AuthenticationReqInner {
username: String,
password: String,
}

#[derive(Deserialize, Debug)]
/// Auth response
pub struct AuthenticationResponse {
pub token: TokenInner,
pub metadata: TokenMeta,
pub message: String,
}

#[derive(Deserialize, Debug)]
/// Jwks response
pub struct JwksResponse {
pub keys: Vec<serde_json::Value>,
}

/// Authenticator client
pub struct Authenticator {
config: AuthenticationConfig,
Expand Down
29 changes: 29 additions & 0 deletions dap-lib/src/auth/message.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use super::token::{TokenInner, TokenMeta};
use serde::{Deserialize, Serialize};

/// Authentication request
#[derive(Serialize)]
pub(super) struct AuthenticationRequest {
pub auth: AuthenticationReqInner,
pub client_id: String,
}
#[derive(Serialize)]
/// Auth req inner
pub(super) struct AuthenticationReqInner {
pub username: String,
pub password: String,
}

#[derive(Deserialize, Debug)]
/// Auth response
pub(super) struct AuthenticationResponse {
pub token: TokenInner,
pub metadata: TokenMeta,
pub message: String,
}

#[derive(Deserialize, Debug)]
/// Jwks response
pub(super) struct JwksResponse {
pub keys: Vec<serde_json::Value>,
}
5 changes: 3 additions & 2 deletions dap-lib/src/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod auth;
mod authenticator;
mod message;
mod token;

pub use auth::Authenticator;
pub use authenticator::Authenticator;
2 changes: 1 addition & 1 deletion dap-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub async fn entrypoint(
authenticator.login().await?;
}

// build global
// // build global
// let globals = Arc::new(Globals {
// proxy_config: proxy_config.clone(),
// runtime_handle: runtime_handle.clone(),
Expand Down

0 comments on commit 856aef2

Please sign in to comment.