Skip to content

Commit 44a7a68

Browse files
committed
feat: expose verified JWT claims as peek_verified_claims conn assign
After verify_peek_auth succeeds, the full decoded claims map is now assigned to conn.assigns[:peek_verified_claims]. This lets downstream apps read any claim (e.g. locale) without re-verifying the token or manually decoding the JWT payload. Previously the claims were parsed and discarded after building peek_account_user, forcing apps to either re-verify or base64-decode the raw token to access additional fields.
1 parent 14c9c80 commit 44a7a68

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

lib/peek_app_sdk/plugs/peek_auth.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ defmodule PeekAppSDK.Plugs.PeekAuth do
5656
|> assign(:peek_install_id, install_id)
5757
|> assign(:peek_account_user, build_account_user(claims))
5858
|> assign(:peek_config_id, config_id)
59+
|> assign(:peek_verified_claims, claims)
5960

6061
_ ->
6162
conn

test/peek_app_sdk/plugs/peek_auth_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ defmodule PeekAppSDK.Plugs.PeekAuthTest do
2727
assert conn.assigns.peek_install_id == install_id
2828
assert conn.assigns.peek_install_token == token
2929
assert conn.assigns.peek_config_id == nil
30+
assert is_map(conn.assigns.peek_verified_claims)
31+
assert conn.assigns.peek_verified_claims["sub"] == install_id
3032

3133
# Don't test session in tests since it's not properly initialized
3234
# and we're now handling that gracefully in the implementation

0 commit comments

Comments
 (0)