legion-crypt 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/legion/crypt/jwt.rb +23 -0
- data/lib/legion/crypt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63ba23115939920477655378eaff3adacb4f37dac754cffc7e888a9eebc8ab08
|
|
4
|
+
data.tar.gz: 88960246bf06ae1e228529958d9e431693a9fa8e8279234ae1498c130bf1490d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: abf411468507856a834cc3e06df344eaecc5deebcb552a77d4cfd30ac1c091506f8b284eea79660d3dc109f2e622816c32871d4c4eda047a51ec3a9dbb689467
|
|
7
|
+
data.tar.gz: 557b616f75af3857df71a6530ea4a7e26680163fc2274e3a09ecfb2a12de628cc9bf64b90fb8e527c8ae43b1ac741a070b3f68d281591369ab460e2e348bd4e8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Legion::Crypt
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [1.5.4] - 2026-04-06
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `JWT.issue_identity_token` — convenience method wrapping `JWT.issue` with identity claims from `Identity::Process` (Wire Format Phase 3); accepts `issuer:` kwarg (defaults to `'legion'`) passed through to `JWT.issue`; normalizes and rejects conflicting string-keyed extra claims before merging
|
|
9
|
+
|
|
3
10
|
## [1.5.3] - 2026-04-06
|
|
4
11
|
|
|
5
12
|
### Added
|
data/lib/legion/crypt/jwt.rb
CHANGED
|
@@ -36,6 +36,29 @@ module Legion
|
|
|
36
36
|
raise
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
def self.issue_identity_token(signing_key:, extra_claims: {}, algorithm: 'HS256', ttl: 3600, issuer: 'legion')
|
|
40
|
+
unless defined?(Legion::Identity::Process) && Legion::Identity::Process.resolved?
|
|
41
|
+
raise ArgumentError,
|
|
42
|
+
'Identity::Process not resolved'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
identity = Legion::Identity::Process.identity_hash
|
|
46
|
+
identity_fields = {
|
|
47
|
+
sub: identity[:canonical_name],
|
|
48
|
+
principal_id: identity[:id],
|
|
49
|
+
canonical_name: identity[:canonical_name],
|
|
50
|
+
kind: identity[:kind].to_s,
|
|
51
|
+
mode: identity[:mode].to_s,
|
|
52
|
+
groups: (identity[:groups] || [])[0, 50]
|
|
53
|
+
}
|
|
54
|
+
normalized_extra_claims = symbolize_keys(extra_claims || {}).reject do |key, _value|
|
|
55
|
+
identity_fields.key?(key)
|
|
56
|
+
end
|
|
57
|
+
payload = normalized_extra_claims.merge(identity_fields)
|
|
58
|
+
|
|
59
|
+
issue(payload, signing_key: signing_key, algorithm: algorithm, ttl: ttl, issuer: issuer)
|
|
60
|
+
end
|
|
61
|
+
|
|
39
62
|
def self.verify(token, verification_key:, **opts)
|
|
40
63
|
algorithm = opts.fetch(:algorithm, 'HS256')
|
|
41
64
|
verify_expiration = opts.fetch(:verify_expiration, true)
|
data/lib/legion/crypt/version.rb
CHANGED