From 6861617e1afcdbea65be47d5926f19c2ece5f34a Mon Sep 17 00:00:00 2001 From: Matthew Scheirer Date: Sat, 7 Oct 2017 19:53:25 -0400 Subject: [PATCH] Reexport claims struct to avoid downstream deps on biscuit --- src/lib.rs | 5 ++++- src/token.rs | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bfc4434..d28b5f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, pub state: Option, pub nonce: Option, diff --git a/src/token.rs b/src/token.rs index 1d676f9..b1efde3 100644 --- a/src/token.rs +++ b/src/token.rs @@ -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; +pub use biscuit::jws::Compact as Jws; +type IdToken = Jws; + +/// 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)) } }