Replies: 2 comments 6 replies
-
I belive that it is exactly like the way you have done it. fn main() {
let cookey_key = "this is the generated cookie key";
struct SecurityAddon;
impl utoipa::Modify for SecurityAddon {
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
if let Some(components) = openapi.components.as_mut() {
components.add_security_scheme(
"sid",
SecurityScheme::ApiKey(ApiKey::Cookie(ApiKeyValue::new(cookie_key))), //<- here
);
} else {
error!("Unable to get openapi components");
}
}
}
} This will set the security scheme available for the OpenAPI but to enforce it to the API or the endpoints you need attach it either to
Same |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to be able to set the SecurityScheme settings at runtime. My application has a session cookie with a key generated in the main method. Is there a way to set that?
Beta Was this translation helpful? Give feedback.
All reactions