Skip to content

Commit

Permalink
chore: updated rust action
Browse files Browse the repository at this point in the history
  • Loading branch information
lmammino committed Oct 29, 2023
1 parent 079c086 commit 0e2b5b9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
test:
runs-on: ubuntu-latest

steps:
Expand All @@ -22,9 +22,6 @@ jobs:
toolchain: stable
components: clippy, rustfmt

- name: Install cargo lambda
run: cargo install --locked cargo-lambda

- uses: actions/cache@v3
with:
path: |
Expand All @@ -47,3 +44,28 @@ jobs:

- name: Run cargo lambda build
run: cargo lambda build --locked --release

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: Install zig
uses: goto-bus-stop/setup-zig@v2

- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo lambda
run: cargo install --locked cargo-lambda
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ A high-performance token-based API Gateway authorizer Lambda that can validate O

⚠️ WIP


TODO: document configuration options
TODO: document what gets added into the context
- TODO: document use case
- TODO: document installation process
- TODO: license and contribution rules
- TODO: document supported algorithms
- TODO: document validation flow
- TODO: document configuration options
- TODO: document what gets added into the context
19 changes: 5 additions & 14 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,10 @@ impl TokenAuthorizerResponse {
) -> Self {
let mut context = HashMap::new();
context.insert("jwt_principal".to_string(), principal_id.to_string());
if let Some(claims) = token_claims.as_object() {
for (key, value) in claims.iter() {
context.insert(
format!("jwt_claim_{}", key),
value
.as_str()
.map(|s| s.to_string())
.unwrap_or_else(|| value.to_string()),
);
}
}
context.insert(
"jwt_claims".to_string(),
serde_json::to_string(token_claims).unwrap(),
);

Self {
context,
Expand Down Expand Up @@ -125,10 +118,8 @@ mod tests {
]
},
"context": {
"jwt_claim_name": "John Doe",
"jwt_claims": "{\"iat\":1516239022,\"name\":\"John Doe\",\"sub\":\"1234567890\"}",
"jwt_principal": "John Doe",
"jwt_claim_sub": "1234567890",
"jwt_claim_iat": "1516239022"
},
"usageIdentifierKey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
})
Expand Down

0 comments on commit 0e2b5b9

Please sign in to comment.