Struct hypers_openapi::OauthConfig
source · #[non_exhaustive]pub struct OauthConfig {
pub client_id: Option<String>,
pub client_secret: Option<String>,
pub realm: Option<String>,
pub app_name: Option<String>,
pub scope_separator: Option<String>,
pub scopes: Option<Vec<String>>,
pub additional_query_string_params: Option<HashMap<String, String>>,
pub use_basic_authentication_with_access_code_grant: Option<bool>,
pub use_pkce_with_authorization_code_grant: Option<bool>,
}Expand description
Object used to alter Swagger UI oauth settings.
§Examples
let config = OauthConfig::new()
.client_id("client-id")
.use_pkce_with_authorization_code_grant(true);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.client_id: Option<String>oauth client_id the Swagger UI is using for auth flow.
client_secret: Option<String>oauth client_secret the Swagger UI is using for auth flow.
realm: Option<String>oauth realm the Swagger UI is using for auth flow. realm query parameter (for oauth1) added to authorizationUrl and tokenUrl.
app_name: Option<String>oauth app_name the Swagger UI is using for auth flow. application name, displayed in authorization popup.
scope_separator: Option<String>oauth scope_separator the Swagger UI is using for auth flow. scope separator for passing scopes, encoded before calling, default value is a space (encoded value %20).
scopes: Option<Vec<String>>oauth scopes the Swagger UI is using for auth flow.Vec<String> of initially selected oauth scopes, default is empty.
additional_query_string_params: Option<HashMap<String, String>>oauth additional_query_string_params the Swagger UI is using for auth flow.
HashMap<String, String> of additional query parameters added to authorizationUrl and tokenUrl
use_basic_authentication_with_access_code_grant: Option<bool>oauth use_basic_authentication_with_access_code_grant the Swagger UI is using for auth flow. Only activated for the accessCode flow. During the authorization_code request to the tokenUrl, pass the Client Password using the HTTP Basic Authentication scheme (Authorization header with Basic base64encode(client_id + client_secret)). The default is false
oauth use_pkce_with_authorization_code_grant the Swagger UI is using for auth flow. Only applies to authorizatonCode flows. Proof Key for Code Exchange brings enhanced security for OAuth public clients.The default is false
Implementations§
source§impl OauthConfig
impl OauthConfig
sourcepub fn client_id(self, client_id: &str) -> Self
pub fn client_id(self, client_id: &str) -> Self
Add client_id into [Config].Method takes one argument which exposes the client_id to the user.
§Examples
let config = OauthConfig::new()
.client_id("client-id");sourcepub fn client_secret(self, client_secret: &str) -> Self
pub fn client_secret(self, client_secret: &str) -> Self
Add client_secret into [Config].
Method takes one argument which exposes the client_secret to the user.
🚨 Never use this parameter in your production environment.
It exposes crucial security information. This feature is intended for dev/test environments only. 🚨
§Examples
let config = OauthConfig::new()
.client_secret("client-secret");sourcepub fn realm(self, realm: &str) -> Self
pub fn realm(self, realm: &str) -> Self
Add realm into [Config].Method takes one argument which exposes the realm to the user.realm query parameter (for oauth1) added to authorizationUrl and tokenUrl.
§Examples
let config = OauthConfig::new()
.realm("realm");sourcepub fn app_name(self, app_name: &str) -> Self
pub fn app_name(self, app_name: &str) -> Self
Add app_name into [Config].Method takes one argument which exposes the app_name to the user.application name, displayed in authorization popup.
§Examples
let config = OauthConfig::new()
.app_name("app-name");sourcepub fn scope_separator(self, scope_separator: &str) -> Self
pub fn scope_separator(self, scope_separator: &str) -> Self
Add scope_separator into [Config].
Method takes one argument which exposes the scope_separator to the user.
scope separator for passing scopes, encoded before calling, default value is a space (encoded value %20).
§Examples
let config = OauthConfig::new()
.scope_separator(",");sourcepub fn scopes(self, scopes: Vec<String>) -> Self
pub fn scopes(self, scopes: Vec<String>) -> Self
Add scopes into [Config].
Method takes one argument which exposes the scopes to the user.
Vec<String> of initially selected oauth scopes, default is empty.
§Examples
let config = OauthConfig::new()
.scopes(vec![String::from("openid")]);sourcepub fn additional_query_string_params(
self,
additional_query_string_params: HashMap<String, String>,
) -> Self
pub fn additional_query_string_params( self, additional_query_string_params: HashMap<String, String>, ) -> Self
Add additional_query_string_params into [Config].
Method takes one argument which exposes the additional_query_string_params to the user.
HashMap<String, String> of additional query parameters added to authorizationUrl and tokenUrl
§Examples
let config = OauthConfig::new()
.additional_query_string_params(HashMap::from([(String::from("a"), String::from("1"))]));sourcepub fn use_basic_authentication_with_access_code_grant(
self,
use_basic_authentication_with_access_code_grant: bool,
) -> Self
pub fn use_basic_authentication_with_access_code_grant( self, use_basic_authentication_with_access_code_grant: bool, ) -> Self
Add use_basic_authentication_with_access_code_grant into [Config].
Method takes one argument which exposes the use_basic_authentication_with_access_code_grant to the user.
Only activated for the accessCode flow. During the authorization_code request to the tokenUrl,
pass the Client Password using the HTTP Basic Authentication scheme
(Authorization header with Basic base64encode(client_id + client_secret)).
The default is false
§Examples
let config = OauthConfig::new()
.use_basic_authentication_with_access_code_grant(true);Add use_pkce_with_authorization_code_grant into [Config].
Method takes one argument which exposes the use_pkce_with_authorization_code_grant to the user.
Only applies to authorizatonCode flows. Proof Key for Code Exchange
brings enhanced security for OAuth public clients.The default is false
§Examples
let config = OauthConfig::new()
.use_pkce_with_authorization_code_grant(true);Trait Implementations§
source§impl Clone for OauthConfig
impl Clone for OauthConfig
source§fn clone(&self) -> OauthConfig
fn clone(&self) -> OauthConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for OauthConfig
impl Debug for OauthConfig
source§impl Default for OauthConfig
impl Default for OauthConfig
source§fn default() -> OauthConfig
fn default() -> OauthConfig
Auto Trait Implementations§
impl Freeze for OauthConfig
impl RefUnwindSafe for OauthConfig
impl Send for OauthConfig
impl Sync for OauthConfig
impl Unpin for OauthConfig
impl UnwindSafe for OauthConfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)