Struct utoipa_swagger_ui::oauth::Config
source · #[non_exhaustive]pub struct Config {
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 = oauth::Config::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 authorizationCode flows. Proof Key for Code Exchange brings enhanced security for OAuth public clients. The default is false
Implementations§
source§impl Config
impl Config
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 = oauth::Config::new()
.client_secret("client-secret");
sourcepub fn scope_separator(self, scope_separator: &str) -> Self
pub fn scope_separator(self, scope_separator: &str) -> Self
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 = oauth::Config::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 = oauth::Config::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 = oauth::Config::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 authorizationCode flows. Proof Key for Code Exchange brings enhanced security for OAuth public clients. The default is false
Examples
let config = oauth::Config::new()
.use_pkce_with_authorization_code_grant(true);