sha256_seal 0.1.6 → 0.1.7

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +2 -2
  3. data/README.md +38 -24
  4. metadata +27 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 315fdea0ce5a82dd8d67b01d083282acee522f691cc3f0aa9b1325efb3ee0866
4
- data.tar.gz: a261366546c346d3e24e3ac1eae6d2d54ef7f01ed54a1fa157d2977c2e60bf92
3
+ metadata.gz: e95ae1ddb44ca61aa91a68db10a46619021f07736d431c1826b36f6eafd0eb36
4
+ data.tar.gz: fb423e6d812bd333615dbec1e5c4ef3bd84532a900901a6571750acf99b09179
5
5
  SHA512:
6
- metadata.gz: ab1a96fb6978c03e74d0648bcc4c9c79c272ad8ee91ae11794f179c401ce61e0a9414436f22b3195e929fc4580f7dbff5324dc02eecb7b6e6da9270fb850a6f5
7
- data.tar.gz: 7a8cdedec7048247f4600cbaa9d84f3060223f45632eb0bd07111fbc19458a37212ea94df3cc7f973d26d6a3e4764e7425e542a4a55a7ba898f0dfe02dd58c05
6
+ metadata.gz: 02d9426b1b2dd0bf32319f4ecd42fe70989810f62e01d11aaeb5f316b3d237b9bd08ab6d27d256c5465d0f06e28a57cd4dafc7cb154bd1cd4057123cad8746d2
7
+ data.tar.gz: e52c05f43c203a29365514aab321508cff5c2b0ad55387a0f9f0fbe3dfeeded50fd30b6da1831e8252bd752caeaf852b6bd4c20bd53710da6d7726525ec45a70
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ # The MIT License
2
2
 
3
- Copyright (c) 2017-2021 Cyril Kato
3
+ Copyright (c) 2017-2022 Cyril Kato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Sha256 Seal 🔏
2
2
 
3
- A tiny library to sign documents, and check their integrity.
3
+ A small library allowing to sign documents, and to check their integrity.
4
+
5
+ ## Status
6
+
7
+ [![Version](https://img.shields.io/github/v/tag/cyril/sha256_seal.rb?label=Version&logo=github)](https://github.com/cyril/sha256_seal.rb/tags)
8
+ [![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/cyril/sha256_seal.rb/main)
9
+ [![Ruby](https://github.com/cyril/sha256_seal.rb/workflows/Ruby/badge.svg?branch=main)](https://github.com/cyril/sha256_seal.rb/actions?query=workflow%3Aruby+branch%3Amain)
10
+ [![RuboCop](https://github.com/cyril/sha256_seal.rb/workflows/RuboCop/badge.svg?branch=main)](https://github.com/cyril/sha256_seal.rb/actions?query=workflow%3Arubocop+branch%3Amain)
11
+ [![License](https://img.shields.io/github/license/cyril/sha256_seal.rb?label=License&logo=github)](https://github.com/cyril/sha256_seal.rb/raw/main/LICENSE.md)
4
12
 
5
13
  ## Installation
6
14
 
@@ -12,15 +20,19 @@ gem "sha256_seal"
12
20
 
13
21
  And then execute:
14
22
 
15
- $ bundle
23
+ ```sh
24
+ bundle install
25
+ ```
16
26
 
17
27
  Or install it yourself as:
18
28
 
19
- $ gem install sha256_seal
29
+ ```sh
30
+ gem install sha256_seal
31
+ ```
20
32
 
21
33
  ## Usage
22
34
 
23
- Sign values and verify signatures of values.
35
+ Sign information and verify their signature.
24
36
 
25
37
  ## Example
26
38
 
@@ -75,48 +87,50 @@ Controller:
75
87
  ```ruby
76
88
  # app/controllers/verified_requests/base_controller.rb
77
89
  module VerifiedRequests
78
- class BaseController < ApplicationController
79
- # @see https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html#method-i-verified_request-3F
80
- def verified_request?
81
- secret = ENV.fetch("CSRF_SECRET_KEY")
82
- document_string = request.original_url.force_encoding("utf-8")
83
- signature_field = request.path_parameters.fetch(:csrf)
84
-
85
- builder = Sha256Seal::Builder.new(document_string, secret, signature_field)
86
- builder.signed_value? || Rails.env.test?
87
- end
88
-
90
+ class BaseController < ::ApplicationController
89
91
  def signed_url(route_method, **options)
90
92
  url_route_method = "#{route_method}_url".to_sym
91
93
  incorrect_csrf = "__CSRF_SECRET_KEY__"
92
94
  url_route_string = public_send(url_route_method, csrf: incorrect_csrf, **options)
93
95
 
94
- replace_incorrect_csrf_by_correct_csrf(url_route_string, incorrect_csrf: incorrect_csrf)
96
+ replace_incorrect_csrf_by_correct_csrf(url_route_string, incorrect_csrf:)
95
97
  end
96
98
  helper_method :signed_url
97
99
 
100
+ private
101
+
98
102
  def replace_incorrect_csrf_by_correct_csrf(value, incorrect_csrf:)
99
- secret = ENV.fetch("CSRF_SECRET_KEY")
103
+ secret = ::ENV.fetch("CSRF_SECRET_KEY")
100
104
  field = incorrect_csrf
101
- builder = Sha256Seal::Builder.new(value, secret, field)
105
+ builder = ::Sha256Seal::Builder.new(value, secret, field)
102
106
  value = builder.signed_value
103
107
  field = builder.send(:signature)
104
- builder = Sha256Seal::Builder.new(value, secret, field)
105
108
 
109
+ builder = ::Sha256Seal::Builder.new(value, secret, field)
106
110
  builder.signed_value
107
111
  end
112
+
113
+ # @see https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html#method-i-verified_request-3F
114
+ # @see https://github.com/rails/rails/blob/8015c2c2cf5c8718449677570f372ceb01318a32/actionpack/lib/action_controller/metal/request_forgery_protection.rb#L333-L341
115
+ def verified_request?
116
+ secret = ::ENV.fetch("CSRF_SECRET_KEY")
117
+ document_string = request.original_url.force_encoding("utf-8")
118
+ signature_field = request.path_parameters.fetch(:csrf)
119
+
120
+ builder = ::Sha256Seal::Builder.new(document_string, secret, signature_field)
121
+ builder.signed_value? || ::Rails.env.test?
122
+ end
108
123
  end
109
124
  end
110
125
  ```
111
126
 
112
127
  View:
113
128
 
114
- ```erb
129
+ ```ruby
115
130
  # app/views/verified_requests/accounts/show.html.erb
116
131
 
117
- <%
118
- signed_url(:verified_request_account, id: 'bob', admin: true) # => "http://0.0.0.0:5000/.405d7c8f14389c9ae7f1d97ff66699093bf2d89d13b4f4280a35d62f9e616259/accounts/bob?admin=true"
119
- %>
132
+ signed_url(:verified_request_account, id: "bob", admin: true)
133
+ # => "http://0.0.0.0:5000/.405d7c8f14389c9ae7f1d97ff66699093bf2d89d13b4f4280a35d62f9e616259/accounts/bob?admin=true"
120
134
  ```
121
135
 
122
136
  ## Versioning
@@ -125,4 +139,4 @@ __Sha256Seal__ uses [Semantic Versioning 2.0.0](https://semver.org/)
125
139
 
126
140
  ## License
127
141
 
128
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
142
+ The [gem](https://rubygems.org/gems/sha256_seal) is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sha256_seal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2022-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,21 +25,35 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: fix
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0.beta4
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0.beta4
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: r_spec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-gitlab-security
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -162,8 +176,9 @@ files:
162
176
  homepage: https://github.com/cyril/sha256_seal.rb
163
177
  licenses:
164
178
  - MIT
165
- metadata: {}
166
- post_install_message:
179
+ metadata:
180
+ rubygems_mfa_required: 'true'
181
+ post_install_message:
167
182
  rdoc_options: []
168
183
  require_paths:
169
184
  - lib
@@ -171,15 +186,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
186
  requirements:
172
187
  - - ">="
173
188
  - !ruby/object:Gem::Version
174
- version: '3.0'
189
+ version: 3.1.2
175
190
  required_rubygems_version: !ruby/object:Gem::Requirement
176
191
  requirements:
177
192
  - - ">="
178
193
  - !ruby/object:Gem::Version
179
194
  version: '0'
180
195
  requirements: []
181
- rubygems_version: 3.2.15
182
- signing_key:
196
+ rubygems_version: 3.3.7
197
+ signing_key:
183
198
  specification_version: 4
184
199
  summary: Seal device with SHA-256 hash function.
185
200
  test_files: []