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);
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
§fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
self
into a collection.fn mapped<U, F, A>(self, f: F) -> SmallVec<A>where
F: FnMut(T) -> U,
A: Array<Item = U>,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute
] value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
[Quirk
] value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition
] value
applies. Replaces any previous condition.
See the crate level docs for more details.
Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);