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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

§use_pkce_with_authorization_code_grant: Option<bool>

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

source

pub fn new() -> Self

Create a new Config for oauth auth flow.

§Examples
let config = oauth::Config::new();
source

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 = oauth::Config::new()
    .client_id("client-id");
source

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");
source

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 = oauth::Config::new()
    .realm("realm");
source

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 = oauth::Config::new()
    .app_name("app-name");
source

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 = oauth::Config::new()
    .scope_separator(",");
source

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")]);
source

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"))]));
source

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);
source

pub fn use_pkce_with_authorization_code_grant( self, use_pkce_with_authorization_code_grant: bool, ) -> Self

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§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Config

source§

fn default() -> Config

Returns the “default value” for a type. Read more
source§

impl Serialize for Config

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more