diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-09-24 14:46:40 -0400 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-09-24 14:46:40 -0400 |
commit | fe58cb13a8dfe9dd2feb994cd3e53094e73b2874 (patch) | |
tree | d5815f46f7514128594325065a55f1db41f5ed3e | |
parent | 47c64d09a04903984a7ff2a115d7c548b46bb9b4 (diff) |
Auth client test
-rw-r--r-- | server/src/main.rs | 20 |
1 files changed, 19 insertions, 1 deletions
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::<CoreResponseType>::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(()) } |