Skip to content

Commit f6ff7dd

Browse files
committed
--wip--
1 parent b5cf1e6 commit f6ff7dd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/authly/grant.cr

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ module Authly
7272
end
7373

7474
private def generate_id_token
75-
if scope.includes? "openid"
75+
if scope.includes? "openid"
7676
payload = Authly.owners.id_token(auth_code["user_id"].as_s)
7777
payload["iss"] = Authly.config.issuer
78+
payload["aud"] = @client_id
79+
payload
7880
Authly.jwt_encode(payload)
7981
end
8082
end

src/authly/owner.cr

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module Authly
22
struct Owner
3+
property id : String = Random::Secure.hex(16)
4+
property name : String = ""
5+
property email : String = ""
36
property username : String
47
property password : String
58

@@ -26,11 +29,13 @@ module Authly
2629
end
2730

2831
def id_token(user_id : String) : Hash(String, String | Int64)
32+
user = find! { |owner| owner.id == user_id }
2933
{
30-
"sub" => Random::Secure.hex(32),
34+
"sub" => user_id,
3135
"iat" => Time.utc.to_unix,
3236
"exp" => 1.hour.from_now.to_unix,
33-
"user_id" => user_id,
37+
"name" => user.name,
38+
"email" => user.email
3439
}
3540
end
3641

0 commit comments

Comments
 (0)