Reexport claims struct to avoid downstream deps on biscuit

This commit is contained in:
Matthew Scheirer 2017-10-07 19:53:25 -04:00
parent b684baa89f
commit 6861617e1a
2 changed files with 9 additions and 4 deletions

View File

@ -18,7 +18,7 @@
//!
//! // ... send your user to auth_url, get an auth_code back at your redirect_url handler
//!
//! let token = client.authenticate(auth_code, Default::default())?;
//! let token = client.authenticate(auth_code, None, None)?;
//! ```
//!
//! That example leaves you with a decoded `Token` that has been validated. Your user is
@ -420,6 +420,9 @@ impl Client {
/// Derives Default, so remember to ..Default::default() after you specify what you want.
#[derive(Default)]
pub struct Options {
/// MUST contain openid. By default this is ONLY openid. Official optional scopes are
/// email, profile, address, phone, offline_access. Check the Discovery config
/// `scopes_supported` to see what is available at your provider!
pub scope: Option<String>,
pub state: Option<String>,
pub nonce: Option<String>,

View File

@ -1,14 +1,16 @@
use base64;
use biscuit::{CompactJson, Empty, SingleOrMultiple};
use biscuit::jws::Compact;
use inth_oauth2::client::response::{FromResponse, ParseError};
use inth_oauth2::token::{self, Bearer, Expiring};
use reqwest::Url;
use serde_json::Value;
use url_serde;
type IdToken = Compact<Claims, Empty>;
pub use biscuit::jws::Compact as Jws;
type IdToken = Jws<Claims, Empty>;
/// ID Token contents. [See spec.](https://openid.net/specs/openid-connect-basic-1_0.html#IDToken)
#[derive(Serialize, Deserialize)]
pub struct Claims {
#[serde(with = "url_serde")] pub iss: Url,
@ -70,7 +72,7 @@ impl Token {
let token = obj.get("id_token").and_then(Value::as_str).ok_or(
ParseError::ExpectedFieldType("id_token", "string"),
)?;
Ok(Compact::new_encoded(token))
Ok(Jws::new_encoded(token))
}
}