-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Locksmith token CHANGELOG entry and cleanup (#1175)
- Loading branch information
1 parent
63141f6
commit 040778f
Showing
8 changed files
with
40 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,7 +215,7 @@ fn build_grant_type_auth_code_post_body( | |
token_name: Option<String>, | ||
) -> Result<HashMap<String, String>> { | ||
let body = hashmap! { | ||
"client_id".to_owned() => LOCKSMITH_CLIENT_ID.to_owned(), | ||
"client_id".to_owned() => Default::default(), | ||
"code".to_owned() => authorization_code.into(), | ||
"code_verifier".to_owned() => code_verfier.into(), | ||
"grant_type".to_owned() => "authorization_code".to_owned(), | ||
|
@@ -317,7 +317,8 @@ pub async fn refresh_tokens( | |
} | ||
} | ||
|
||
pub async fn handle_refresh_tokens( | ||
/// Get a new access token using the refresh token. | ||
pub async fn renew_access_token( | ||
refresh_token: &RefreshToken, | ||
ignore_certs: bool, | ||
api_uri: &str, | ||
|
@@ -342,16 +343,34 @@ pub struct LocksmithTokenResponse { | |
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct UserInfo { | ||
pub email: String, | ||
pub sub: Option<String>, | ||
pub name: Option<String>, | ||
pub given_name: Option<String>, | ||
pub family_name: Option<String>, | ||
pub preferred_username: Option<String>, | ||
pub email_verified: Option<bool>, | ||
} | ||
|
||
impl UserInfo { | ||
pub fn identity(&self) -> String { | ||
match &self.name { | ||
Some(name) => format!("{} <{}>", name, self.email), | ||
None => format!("<{}>", self.email), | ||
} | ||
} | ||
} | ||
|
||
/// Keycloak error response. | ||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct ResponseError { | ||
error: String, | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
|
||
#[test] | ||
fn user_info_identity() { | ||
let named = UserInfo { email: "[email protected]".into(), name: Some("John Doe".into()) }; | ||
assert_eq!(named.identity(), "John Doe <[email protected]>"); | ||
|
||
let nameless = UserInfo { email: "[email protected]".into(), name: None }; | ||
assert_eq!(nameless.identity(), "<[email protected]>"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters