From fe58cb13a8dfe9dd2feb994cd3e53094e73b2874 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 24 Sep 2022 14:46:40 -0400 Subject: Auth client test --- server/src/main.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/server/src/main.rs b/server/src/main.rs index b60f699..f751c4d 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -29,7 +29,25 @@ async fn main() -> Result<(), anyhow::Error> { IssuerUrl::new("https://auth.orbekk.com/realms/test".to_string())?, async_http_client, ).await?; - log::debug!("{:?}", provider_metadata); + + let client = + CoreClient::from_provider_metadata( + provider_metadata, + ClientId::new("test-client".to_string()), + Some(ClientSecret::new("EbIMIpGnYPrG1GBl6eZtVM5zIhiuu5p1".to_string())), + ) + // Set the URL the user will be redirected to after the authorization process. + .set_redirect_uri(RedirectUrl::new("https://bridge.orbekk.com/keycloak-callback".to_string())?); + + let (auth_url, csrf_token, nonce) = client + .authorize_url(AuthenticationFlow::::AuthorizationCode, + CsrfToken::new_random, + Nonce::new_random) + .add_scope(Scope::new("profile".to_string())) + .url(); + + log::info!("{:?}", auth_url); + rocket::build().mount("/", routes![index]).launch().await; Ok(()) } -- cgit v1.2.3