Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
feat: allow for a user specified redirect url root
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Farshidmehr <[email protected]>
  • Loading branch information
definitelynobody committed Jul 6, 2022
1 parent 5b2231e commit 51620d2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ static OUT: Lazy<RwLock<HashMap<Uuid, Arc<Mutex<State>>>>> =
#[clap(author, version, about)]
struct Args {
/// Address to bind to.
#[clap(long, default_value_t = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 3000))]
#[clap(long, default_value_t = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 3000))]
addr: SocketAddr,

/// Externally accessible root URL.
/// For example: https://benefice.example.com
#[clap(long)]
url: Url,

/// Maximum jobs.
#[clap(long, default_value_t = num_cpus::get())]
jobs: usize,
Expand Down Expand Up @@ -97,6 +102,7 @@ struct Args {
async fn main() -> anyhow::Result<()> {
let Args {
addr,
url,
jobs,
timeout,
command,
Expand Down Expand Up @@ -144,18 +150,14 @@ async fn main() -> anyhow::Result<()> {
.with(tracing_subscriber::fmt::layer())
.init();

let redirect_url = format!("https://{addr}/authorized");
let issuer_url = IssuerUrl::from_url(oidc_issuer);
let provider_metadata = CoreProviderMetadata::discover(&issuer_url, http_client)?;
let openid_client = CoreClient::from_provider_metadata(
provider_metadata,
ClientId::new(oidc_client),
oidc_secret.map(ClientSecret::new),
)
.set_redirect_uri(
RedirectUrl::new(redirect_url)
.with_context(|| "failed to parse redirect url".to_string())?,
)
.set_redirect_uri(RedirectUrl::from_url(url))
.set_auth_type(AuthType::RequestBody);

let app = Router::new()
Expand Down

0 comments on commit 51620d2

Please sign in to comment.