#[macro_use] extern crate rocket; #[get("/")] fn index() -> &'static str { "Hello, World!" } #[rocket::main] async fn main() -> Result<(), anyhow::Error> { dotenv::dotenv().ok(); env_logger::init(); log::debug!("hello"); use openidconnect::core::{ CoreAuthenticationFlow, CoreClient, CoreProviderMetadata, CoreResponseType, CoreUserInfoClaims, }; use openidconnect::{ AccessTokenHash, AuthenticationFlow, AuthorizationCode, ClientId, ClientSecret, CsrfToken, IssuerUrl, Nonce, PkceCodeChallenge, RedirectUrl, Scope, }; use openidconnect::reqwest::async_http_client; use openidconnect::url::Url; // // Use OpenID Connect Discovery to fetch the provider metadata. use openidconnect::{OAuth2TokenResponse, TokenResponse}; let provider_metadata = CoreProviderMetadata::discover_async( IssuerUrl::new("https://auth.orbekk.com/realms/test".to_string())?, async_http_client, ).await?; 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(()) }