Browse Source

Improve documentation on Provider specification.

master
Jeb Rosen 1 month ago
parent
commit
fff1fdda87
2 changed files with 32 additions and 2 deletions
  1. +26
    -0
      src/lib.rs
  2. +6
    -2
      src/provider.rs

+ 26
- 0
src/lib.rs View File

@@ -124,6 +124,32 @@
//! # ;
//! # }
//! ```
//!
//! ### Provider selection
//!
//! Providers can be specified as a known provider name (case-insensitive). The
//! known provider names are listed as associated constants on the
//! [`StaticProvider`] type.
//!
//! ```toml
//! [global.oauth.github]
//! # Using a known provider name
//! provider = "GitHub"
//! client_id = "..."
//! client_secret = "..."
//! redirect_uri = "http://localhost:8000/auth/github"
//! ```
//!
//! The provider can also be specified as a table with `auth_uri` and
//! `token_uri` values:
//!
//! ```toml
//! [global.oauth.custom]
//! provider = { auth_uri = "https://example.com/oauth/authorize", token_uri = "https://example.com/oauth/token" }
//! client_id = "..."
//! client_secret = "..."
//! redirect_uri = "http://localhost:8000/auth/custom"
//! ```

#![warn(future_incompatible, nonstandard_style, missing_docs)]



+ 6
- 2
src/provider.rs View File

@@ -13,8 +13,12 @@ pub trait Provider: Send + Sync + 'static {
fn token_uri(&self) -> Cow<'_, str>;
}

/// A `StaticProvider` contains the authorization and token exchange URIs
/// specific to a known OAuth service provider.
/// A `StaticProvider` contains authorization and token exchange URIs specific
/// to an OAuth service provider, that will not change after they are
/// determined.
///
/// If the service provider's URIs might change at runtime, implement
/// [`Provider`] for your own type instead.
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct StaticProvider {
/// The authorization URI associated with the service provider.


Loading…
Cancel
Save