base64_token 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitlab-ci.yml +42 -0
- data/.rubocop.yml +3 -59
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/base64_token.gemspec +9 -9
- data/lib/base64_token/version.rb +2 -1
- data/lib/base64_token.rb +4 -5
- metadata +18 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a052821e65848e2fc2c1ad7e166907d45f61f196f098cb2dc20758980b88ea04
|
4
|
+
data.tar.gz: dc0bfdf22294ed08bf7b6bea5441080cc9261688e8975fd53812ce26c72f3e4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9da3e47cdf5e0ffa5e81be2280609892ba5a947ba0440fb50b6a60382981c879c72a0d758d15a281cb0ebc29274bdad088a8434b28868b598182a2857ca1eb89
|
7
|
+
data.tar.gz: 176ca5eda82a21d23cb80d108a94e6f77a95e4ffe9481d7d872a066709a4b908d9546e417aeae0f25e51695e51bf091b188eb5c2040427c0ac7feab79598c360
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
image: ruby:3.1
|
2
|
+
|
3
|
+
stages:
|
4
|
+
- test
|
5
|
+
- publish
|
6
|
+
|
7
|
+
before_script:
|
8
|
+
- bundle config jobs 8
|
9
|
+
- bundle install --path=/tmp/bundler --quiet
|
10
|
+
- apt update && apt install -y libsodium-dev
|
11
|
+
|
12
|
+
rubocop:
|
13
|
+
stage: test
|
14
|
+
image: ruby:2.7
|
15
|
+
script:
|
16
|
+
- bundle exec rubocop
|
17
|
+
|
18
|
+
rspec_2.7:
|
19
|
+
stage: test
|
20
|
+
image: ruby:2.7
|
21
|
+
script:
|
22
|
+
- bundle exec rspec
|
23
|
+
|
24
|
+
rspec:
|
25
|
+
stage: test
|
26
|
+
script:
|
27
|
+
- bundle exec rspec
|
28
|
+
|
29
|
+
publish_gem:
|
30
|
+
stage: publish
|
31
|
+
script:
|
32
|
+
- mkdir -p ~/.gem
|
33
|
+
- |
|
34
|
+
cat << EOF > ~/.gem/credentials
|
35
|
+
---
|
36
|
+
:rubygems_api_key: ${RUBYGEMS_API_KEY}
|
37
|
+
EOF
|
38
|
+
- chmod 0600 ~/.gem/credentials
|
39
|
+
- gem build base64_token.gemspec
|
40
|
+
- gem push $(find `pwd` -name "base64_token-*.gem")
|
41
|
+
only:
|
42
|
+
- main
|
data/.rubocop.yml
CHANGED
@@ -1,59 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Metrics/BlockLength:
|
5
|
-
ExcludedMethods:
|
6
|
-
- describe
|
7
|
-
- namespace
|
8
|
-
|
9
|
-
Style/AsciiComments:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
Style/Documentation:
|
13
|
-
Enabled: false
|
14
|
-
|
15
|
-
# Encoding comments are not neccessary in all 2.x versions of ruby, since
|
16
|
-
# UTF-8 has become the default encoding.
|
17
|
-
Style/Encoding:
|
18
|
-
EnforcedStyle: never
|
19
|
-
Enabled: true
|
20
|
-
Exclude:
|
21
|
-
- '*.gemspec'
|
22
|
-
|
23
|
-
# Ruby 2.3 introduced optional automatic freezing of string literals
|
24
|
-
# This might become default in future versions.
|
25
|
-
# For details on this feature see the internet, e.g. https://wyeworks.com/blog/2015/12/1/immutable-strings-in-ruby-2-dot-3
|
26
|
-
Style/FrozenStringLiteralComment:
|
27
|
-
EnforcedStyle: always
|
28
|
-
|
29
|
-
# This cop tries to make you use module_funtion instead of extend self
|
30
|
-
# This is bad because both have their own use-case and should not be used
|
31
|
-
# and sometimes cannot be used to do the same thing
|
32
|
-
Style/ModuleFunction:
|
33
|
-
Enabled: false
|
34
|
-
|
35
|
-
# While it is very often useful to separate numbers after every three digits
|
36
|
-
# for readability, this mostly doesn't make sense if the number doesn't
|
37
|
-
# represent an amount but rather an identifier. Thus the use of underscores
|
38
|
-
# every three digits is recommended but not enforced.
|
39
|
-
Style/NumericLiterals:
|
40
|
-
Enabled: false
|
41
|
-
|
42
|
-
# Do not force the same one letter variable names for all occurences of inject
|
43
|
-
Style/SingleLineBlockParams:
|
44
|
-
Enabled: false
|
45
|
-
|
46
|
-
# No significant improvement in speed or memory usage apparent. Readability is
|
47
|
-
# atrocious.
|
48
|
-
Performance/Casecmp:
|
49
|
-
Enabled: false
|
50
|
-
|
51
|
-
# Not safe in a rails context, since Relation.count is != Enumerable.count
|
52
|
-
Performance/Count:
|
53
|
-
Enabled: false
|
54
|
-
|
55
|
-
# Does not make sense when dealing with non-ActiveRecord like mongoid. That
|
56
|
-
# Mongoid for example throws error if find_by returns nothing (but we expect
|
57
|
-
# nil)
|
58
|
-
Rails/FindBy:
|
59
|
-
Enabled: false
|
1
|
+
inherit_gem:
|
2
|
+
aroundhome_cops:
|
3
|
+
- default.yml
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 2.0.0 (2022-10-24)
|
2
|
+
|
3
|
+
* Breaking: Update minimum versions of Ruby and RbNaCl
|
4
|
+
* This also drops support for `rbnacl-libsodium`, which means libsodium is now required
|
5
|
+
to be preinstalled on the OS level
|
6
|
+
* Note: `#generate` expects named parameters, not a hash (which is important for Ruby 2.7+)
|
7
|
+
|
1
8
|
## 1.0.2 (2018-02-23)
|
2
9
|
|
3
10
|
* Use `Base.strict_encode64` to encode the secret key
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/base64_token.gemspec
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
|
3
|
+
|
4
|
+
lib = File.expand_path('lib', __dir__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
6
|
require 'base64_token/version'
|
6
7
|
|
7
8
|
Gem::Specification.new do |spec|
|
8
9
|
spec.name = 'base64_token'
|
9
10
|
spec.version = Base64Token::VERSION
|
10
|
-
spec.authors = ['
|
11
|
-
spec.email = ['oss@
|
11
|
+
spec.authors = ['be Around GmbH']
|
12
|
+
spec.email = ['oss@aroundhome.de']
|
12
13
|
spec.summary = 'Encodes ruby hashes as encrypted and URL-safe tokens.'
|
13
|
-
spec.homepage = 'https://github.com/
|
14
|
+
spec.homepage = 'https://github.com/aroundhome/base64_token'
|
14
15
|
spec.license = 'MIT'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -20,13 +21,12 @@ Gem::Specification.new do |spec|
|
|
20
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
22
|
spec.require_paths = ['lib']
|
22
23
|
|
23
|
-
spec.required_ruby_version = '>= 2.
|
24
|
+
spec.required_ruby_version = '>= 2.7.0'
|
24
25
|
|
25
|
-
spec.add_dependency 'rbnacl', '>=
|
26
|
-
spec.add_dependency 'rbnacl-libsodium', '~> 1.0'
|
26
|
+
spec.add_dependency 'rbnacl', '>= 6.0.0', '< 8.0'
|
27
27
|
|
28
|
-
spec.add_development_dependency '
|
28
|
+
spec.add_development_dependency 'aroundhome_cops', '~> 4.0'
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
29
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
31
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
-
spec.add_development_dependency 'rubocop', '0.47.1'
|
32
32
|
end
|
data/lib/base64_token/version.rb
CHANGED
data/lib/base64_token.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'base64'
|
3
4
|
require 'base64_token/version'
|
4
5
|
require 'json'
|
5
6
|
|
6
|
-
require 'rbnacl/libsodium'
|
7
7
|
require 'rbnacl'
|
8
8
|
|
9
9
|
module Base64Token
|
@@ -19,9 +19,10 @@ module Base64Token
|
|
19
19
|
|
20
20
|
def parse(token)
|
21
21
|
return {} if !token || token.strip.empty?
|
22
|
+
|
22
23
|
cipher = base64_decode(token)
|
23
24
|
json = decrypt(cipher)
|
24
|
-
JSON.parse(json).
|
25
|
+
JSON.parse(json).transform_keys(&:to_sym)
|
25
26
|
end
|
26
27
|
|
27
28
|
def generate_key
|
@@ -55,9 +56,7 @@ module Base64Token
|
|
55
56
|
|
56
57
|
def crypto_box
|
57
58
|
@crypto_box ||= begin
|
58
|
-
unless @encryption_key
|
59
|
-
raise ConfigurationError, 'Encryption key not set.'
|
60
|
-
end
|
59
|
+
raise ConfigurationError, 'Encryption key not set.' unless @encryption_key
|
61
60
|
|
62
61
|
key = Base64.decode64(@encryption_key)
|
63
62
|
RbNaCl::SimpleBox.from_secret_key(key)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base64_token
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- be Around GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbnacl
|
@@ -16,48 +16,48 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 6.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: aroundhome_cops
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
type: :
|
39
|
+
version: '4.0'
|
40
|
+
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '4.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '2.0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '2.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rake
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +86,15 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '3.0'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: rubocop
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - '='
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: 0.47.1
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - '='
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 0.47.1
|
103
89
|
description:
|
104
90
|
email:
|
105
|
-
- oss@
|
91
|
+
- oss@aroundhome.de
|
106
92
|
executables: []
|
107
93
|
extensions: []
|
108
94
|
extra_rdoc_files: []
|
109
95
|
files:
|
110
96
|
- ".gitignore"
|
97
|
+
- ".gitlab-ci.yml"
|
111
98
|
- ".rspec"
|
112
99
|
- ".rubocop.yml"
|
113
100
|
- ".travis.yml"
|
@@ -121,7 +108,7 @@ files:
|
|
121
108
|
- bin/setup
|
122
109
|
- lib/base64_token.rb
|
123
110
|
- lib/base64_token/version.rb
|
124
|
-
homepage: https://github.com/
|
111
|
+
homepage: https://github.com/aroundhome/base64_token
|
125
112
|
licenses:
|
126
113
|
- MIT
|
127
114
|
metadata: {}
|
@@ -133,15 +120,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
120
|
requirements:
|
134
121
|
- - ">="
|
135
122
|
- !ruby/object:Gem::Version
|
136
|
-
version: 2.
|
123
|
+
version: 2.7.0
|
137
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
125
|
requirements:
|
139
126
|
- - ">="
|
140
127
|
- !ruby/object:Gem::Version
|
141
128
|
version: '0'
|
142
129
|
requirements: []
|
143
|
-
|
144
|
-
rubygems_version: 2.6.13
|
130
|
+
rubygems_version: 3.3.7
|
145
131
|
signing_key:
|
146
132
|
specification_version: 4
|
147
133
|
summary: Encodes ruby hashes as encrypted and URL-safe tokens.
|