feat: forge adapter to get redirect URI for OAuth authorization req
This commit is contained in:
parent
51ac3e4977
commit
253c26227c
3 changed files with 49 additions and 0 deletions
9
src/forge/auth/application/port/out/forge/errors.rs
Normal file
9
src/forge/auth/application/port/out/forge/errors.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use derive_more::Display;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub type OutForgePortResult<V> = Result<V, OutForgePortError>;
|
||||
|
||||
#[derive(Debug, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum OutForgePortError {
|
||||
InteralError,
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
use super::errors::*;
|
||||
use url::Url;
|
||||
|
||||
pub trait GetRedirectUri: Send + Sync {
|
||||
fn get_redirect_uri(
|
||||
&self,
|
||||
state: &str,
|
||||
process_authorization_response_uri: &Url,
|
||||
) -> OutForgePortResult<Url>;
|
||||
}
|
30
src/forge/auth/application/port/out/forge/mod.rs
Normal file
30
src/forge/auth/application/port/out/forge/mod.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
pub mod errors;
|
||||
pub mod get_redirect_uri;
|
||||
pub mod refresh_access_token;
|
||||
pub mod request_access_token;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use url::Url;
|
||||
|
||||
use super::*;
|
||||
|
||||
use errors::*;
|
||||
use get_redirect_uri::GetRedirectUri;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct MockForge; // {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl GetRedirectUri for MockForge {
|
||||
fn get_redirect_uri(
|
||||
&self,
|
||||
state: &str,
|
||||
process_authorization_response_uri: &Url,
|
||||
) -> OutForgePortResult<Url> {
|
||||
let mut u = process_authorization_response_uri.clone();
|
||||
u.set_query(Some(&format!("state={state}")));
|
||||
Ok(u)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue