Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actix - not found in this scope #581

Open
reburguer opened this issue Nov 20, 2024 · 0 comments
Open

actix - not found in this scope #581

reburguer opened this issue Nov 20, 2024 · 0 comments

Comments

@reburguer
Copy link

use actix_web::{get, App, HttpResponse, HttpServer, Responder};

#[cfg(feature = "actix")]
use zitadel::actix::introspection::{IntrospectedUser, IntrospectionConfigBuilder};

#[get("/unauthed")]
async fn unauthed() -> impl Responder {
println!("Hello Unauthorized User!");
HttpResponse::Ok().body("Hello Unauthorized User!")
}

#[get("/authed")]
async fn authed(user: IntrospectedUser) -> impl Responder {
println!("Hello Authorized User!");
format!(
"Hello Authorized {:?} with id {}",
user.username, user.user_id
)
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
println!("Starting server.");
#[cfg(feature = "actix")]
let auth = IntrospectionConfigBuilder::new("https://zitadel-libraries-l8boqa.zitadel.cloud")
.with_basic_auth(
"194339055499018497@zitadel_rust_test",
"Ip56oGzxKL1rJ8JaleUVKL7qUlpZ1tqHQYRSd6JE1mTlTJ3pDkDzoObHdZsOg88B",
)
.build()
.await
.unwrap();
HttpServer::new(move || {
App::new()
.app_data(auth.clone())
.service(unauthed)
.service(authed)
})
.bind(("0.0.0.0", 8080))?
.run()
.await
}

.app_data(auth.clone())
| ^^^^^^^^ not found in this scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant