diff --git a/CHANGELOG.md b/CHANGELOG.md index fd1be9b..82318d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [15.0.0] - 2021-04-16 + +### Added +- username to verify endpoint and JWT + +### Updated +- Updated README + ## [14.1.2] - 2021-04-15 ### Updated diff --git a/Cargo.lock b/Cargo.lock index 4fca7b8..6ee3288 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "broker" -version = "14.1.2" +version = "15.0.0" dependencies = [ "anyhow", "async-std", diff --git a/Cargo.toml b/Cargo.toml index ada3792..b6b50d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "broker" -version = "14.1.2" +version = "15.0.0" authors = ["Bevan Hunt "] edition = "2018" license = "MIT" diff --git a/README.md b/README.md index 849c8eb..1c13e3d 100644 --- a/README.md +++ b/README.md @@ -147,12 +147,13 @@ GET /verify will return: `200` or `500` or `401` -200 - will return a biscuit public key, biscuit token, and JWT expiry for your microservice (use from_bytes to hydrate the key and token) +200 - will return a biscuit public key, biscuit token, username, and JWT expiry for your microservice (use from_bytes to hydrate the key and token) ```json { "key": [136,133,229,196,134,20,240,80,159,158,154,20,57,35,198,7,156,160,193,224,174,209,51,150,27,86,75,122,172,24,114,66], "token": [122,133,229,196,134,20,240,80,159,158,154,20,57,35,198,7,156,160,193,224,174,209,51,150,27,86,75,122,172,24,114,121], - "expiry: 1618352841 + "expiry": 1618352841, + "username": "bob", } ``` diff --git a/src/main.rs b/src/main.rs index 2ba65ae..c25b607 100644 --- a/src/main.rs +++ b/src/main.rs @@ -311,7 +311,7 @@ fn puts_event(event: Event) -> Result<()> { Ok(()) } -fn jwt_aud(scopes: Vec, exp: i64) -> Result> { +fn jwt_aud(scopes: Vec, exp: i64, username: String) -> Result> { let biscuit_root = KeyPair::new(); let biscuit_public_key = biscuit_root.public(); let public_key_bytes = biscuit_public_key.to_bytes(); @@ -331,7 +331,7 @@ fn jwt_aud(scopes: Vec, exp: i64) -> Result> { } let biscuit = builder.build()?; - Ok(Some(json!({"key": public_key_bytes, "token": biscuit.to_vec()?, "expiry": exp}).to_string())) + Ok(Some(json!({"key": public_key_bytes, "token": biscuit.to_vec()?, "expiry": exp, "username": username}).to_string())) } fn user_create(user_form: UserForm) -> Result> { @@ -457,7 +457,7 @@ async fn create_jwt(login: LoginForm) -> Result> { let aud: String; match user.scopes.clone() { Some(scopes) => { - match jwt_aud(scopes, exp)? { + match jwt_aud(scopes, exp, user.clone().username)? { Some(a) => { aud = a; }, @@ -483,7 +483,7 @@ async fn create_jwt(login: LoginForm) -> Result> { let aud: String; match user.scopes.clone() { Some(scopes) => { - match jwt_aud(scopes, exp)? { + match jwt_aud(scopes, exp, user.clone().username)? { Some(a) => { aud = a; }, @@ -505,7 +505,7 @@ async fn create_jwt(login: LoginForm) -> Result> { let aud: String; match user.scopes.clone() { Some(scopes) => { - match jwt_aud(scopes, exp)? { + match jwt_aud(scopes, exp, user.clone().username)? { Some(a) => { aud = a; }, @@ -599,7 +599,7 @@ async fn jwt_verify(token: String) -> Result>> { let aud: String; match user.scopes.clone() { Some(scopes) => { - match jwt_aud(scopes, exp)? { + match jwt_aud(scopes, exp, user.clone().username)? { Some(a) => { aud = a; },