jwt-eddsa 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/.ruby-version +1 -0
- data/README.md +24 -1
- data/lib/jwt/eddsa/version.rb +1 -1
- data/lib/jwt/eddsa.rb +25 -2
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 397516e999d09d5630932c9e83855bdcdca32a4ce1ea5c3727bc8a69cdf0488a
|
4
|
+
data.tar.gz: 120eb2ca3c66104aa8023063c96077e7e3b158388f292b766546d58eb86c8a09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7da8d363b401a7d741539941d99be57eca69fb1c2a09cf8d6eaa0431da4346952e8d4711df1518bee69cce5bf77d762d6ea45e0e2cbb4bd0a96e581019b164a3
|
7
|
+
data.tar.gz: 5027b733b26cc75604395f972db17eadfe6757219a749ed1094e0bbcfa8a056bcc49cca060dc14ea71cb33c844485324a742acd793003b4445cac0fec8b4141f
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion:
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
3
5
|
|
4
6
|
Style/StringLiterals:
|
5
7
|
EnforcedStyle: double_quotes
|
6
8
|
|
7
9
|
Style/StringLiteralsInInterpolation:
|
8
10
|
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Exclude:
|
14
|
+
- spec/**/*_spec.rb
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.4
|
data/README.md
CHANGED
@@ -2,14 +2,37 @@
|
|
2
2
|
|
3
3
|
A library extending the ruby-jwt gem with EdDSA algorithms
|
4
4
|
|
5
|
+
**NOTE: This gem is still WIP**
|
6
|
+
|
7
|
+
Work is currently done in [ruby-jwt](https://github.com/jwt/ruby-jwt/pull/607) to allow extending the algorithms.
|
8
|
+
|
9
|
+
Plan is to replace rbnacl with something else in the near future.
|
10
|
+
|
5
11
|
## Installation
|
6
12
|
|
13
|
+
Will only work with the WIP branch, so adding the following to your the Gemfile should do the trick:
|
14
|
+
```
|
15
|
+
gem "jwt", github: "anakinj/ruby-jwt", branch: "extendable-algos"
|
16
|
+
```
|
17
|
+
|
18
|
+
```
|
19
|
+
require "jwt/eddsa" # not verified if this actually works
|
20
|
+
```
|
21
|
+
|
7
22
|
## Usage
|
8
23
|
|
9
|
-
|
24
|
+
```ruby
|
25
|
+
private_key = RbNaCl::Signatures::Ed25519::SigningKey.new("b" * 32)
|
26
|
+
token = JWT.encode({pay: "load"}, private_key, "EdDSA")
|
27
|
+
payload, header = JWT.decode(token, private_key.verify_key, true, algorithm: "EdDSA")
|
28
|
+
```
|
10
29
|
|
11
30
|
## Development
|
12
31
|
|
32
|
+
```
|
33
|
+
bundle install
|
34
|
+
bundle exec rspec
|
35
|
+
```
|
13
36
|
|
14
37
|
## Contributing
|
15
38
|
|
data/lib/jwt/eddsa/version.rb
CHANGED
data/lib/jwt/eddsa.rb
CHANGED
@@ -1,10 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "jwt"
|
3
4
|
require_relative "eddsa/version"
|
4
5
|
|
5
6
|
module JWT
|
7
|
+
# EdDSA algorithm implementation
|
6
8
|
module Eddsa
|
7
|
-
|
8
|
-
|
9
|
+
include JWT::JWA::Algorithm
|
10
|
+
|
11
|
+
register_algorithm("EdDSA")
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def sign(_algorithm, msg, key)
|
15
|
+
unless key.is_a?(RbNaCl::Signatures::Ed25519::SigningKey)
|
16
|
+
raise_sign_error!("Key given is a #{key.class} but needs to be a RbNaCl::Signatures::Ed25519::SigningKey")
|
17
|
+
end
|
18
|
+
|
19
|
+
key.sign(msg)
|
20
|
+
end
|
21
|
+
|
22
|
+
def verify(_algorithm, public_key, signing_input, signature)
|
23
|
+
unless public_key.is_a?(RbNaCl::Signatures::Ed25519::VerifyKey)
|
24
|
+
raise_verify_error!("Key given is a #{public_key.class} but needs to be a RbNaCl::Signatures::Ed25519::VerifyKey")
|
25
|
+
end
|
26
|
+
|
27
|
+
public_key.verify(signature, signing_input)
|
28
|
+
rescue RbNaCl::CryptoError
|
29
|
+
false
|
30
|
+
end
|
31
|
+
end
|
9
32
|
end
|
10
33
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwt-eddsa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Antman
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jwt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.8.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.8.2
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rbnacl
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,7 +38,7 @@ dependencies:
|
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '6.0'
|
27
|
-
description:
|
41
|
+
description:
|
28
42
|
email:
|
29
43
|
- antmanj@gmail.com
|
30
44
|
executables: []
|
@@ -33,6 +47,7 @@ extra_rdoc_files: []
|
|
33
47
|
files:
|
34
48
|
- ".rspec"
|
35
49
|
- ".rubocop.yml"
|
50
|
+
- ".ruby-version"
|
36
51
|
- CHANGELOG.md
|
37
52
|
- CODE_OF_CONDUCT.md
|
38
53
|
- LICENSE
|
@@ -46,8 +61,9 @@ licenses:
|
|
46
61
|
metadata:
|
47
62
|
homepage_uri: https://github.com/anakinj/jwt-eddsa
|
48
63
|
source_code_uri: https://github.com/anakinj/jwt-eddsa
|
49
|
-
changelog_uri: https://github.com/anakinj/jwt-eddsablob/v0.
|
50
|
-
|
64
|
+
changelog_uri: https://github.com/anakinj/jwt-eddsablob/v0.2.0/CHANGELOG.md
|
65
|
+
rubygems_mfa_required: 'true'
|
66
|
+
post_install_message:
|
51
67
|
rdoc_options: []
|
52
68
|
require_paths:
|
53
69
|
- lib
|
@@ -62,8 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
78
|
- !ruby/object:Gem::Version
|
63
79
|
version: '0'
|
64
80
|
requirements: []
|
65
|
-
rubygems_version: 3.5.
|
66
|
-
signing_key:
|
81
|
+
rubygems_version: 3.5.11
|
82
|
+
signing_key:
|
67
83
|
specification_version: 4
|
68
84
|
summary: Extension for the jwt gem
|
69
85
|
test_files: []
|