about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2018-09-04T09·53+0200
committerVincent Ambo <mail@tazj.in>2018-09-04T10·45+0200
commit7c992207233e39cc6fabb915f0e76d8670a38f70 (patch)
treeb9a5987e283b65a44574a6047ef41ffa54469ef2 /src
parentb6eedbfe16938424ac2f677d5f81d6e1c6868849 (diff)
refactor: Pass 'String' to token_kid instead of internal type
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs6
-rw-r--r--src/tests.rs2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f8ae81591ed5..5d8f0ea39b04 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -113,7 +113,7 @@ impl JWKS {
 
 /// Representation of an undecoded JSON Web Token. See [RFC
 /// 7519](https://tools.ietf.org/html/rfc7519).
-pub struct JWT (String);
+struct JWT (String);
 
 /// Representation of a decoded and validated JSON Web Token.
 ///
@@ -181,10 +181,10 @@ impl From<serde_json::Error> for ValidationError {
 ///
 /// This is only safe if the key set containing the currently allowed
 /// key IDs is fetched from a trusted source.
-pub fn token_kid(jwt: &JWT) -> JWTResult<Option<String>> {
+pub fn token_kid(token: &str) -> JWTResult<Option<String>> {
     // Fetch the header component of the JWT by splitting it out and
     // dismissing the rest.
-    let parts: Vec<&str> = jwt.0.splitn(2, '.').collect();
+    let parts: Vec<&str> = token.splitn(2, '.').collect();
     if parts.len() != 2 {
         return Err(ValidationError::MalformedJWT);
     }
diff --git a/src/tests.rs b/src/tests.rs
index 9edd7c12adaa..ddccb764ad03 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -21,7 +21,7 @@ fn test_decode_find_jwks() {
 
 #[test]
 fn test_token_kid() {
-    let jwt = JWT("eyJraWQiOiI4ckRxOFB3MEZaY2FvWFdURVZRbzcrVGYyWXpTTDFmQnhOS1BDZWJhYWk0PSIsImFsZyI6IlJTMjU2IiwidHlwIjoiSldUIn0.eyJpc3MiOiJhdXRoL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JSBcmGWze3UNE2YH_VLD7NCwH2kkqr3gh8rn7lWKG4AUIYPxsw9CB";
 
     let kid = token_kid(&jwt).expect("Failed to extract token KID");
     assert_eq!(Some("8rDq8Pw0FZcaoXWTEVQo7+Tf2YzSL1fBxNKPCebaai4=".into()),