nexus_cqrs_auth 0.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3fe50086ea1962e4813c846b561aa4f6eaaac1fea932fec62c7344cde12a26e4
4
+ data.tar.gz: c8e3d4d182efe23bf2d23ca0024be3d08ffc1c4f6fe97daf42b7bd67d4c91f1b
5
+ SHA512:
6
+ metadata.gz: d0016666660572c0d12788c1636076112179aecfdb07fa147a434d30c6750e0054d5a2c2f6de706d4fba16eeefb9427d5e247c468abd60fc03bae6898ae1754b
7
+ data.tar.gz: 3666dcbd9cdf2e2bac16c4d643ffac1b3220261cdcfac31b53fb6b605f307b380297214fb10c9a5e159b1a037164927e9773d1944764d19a5d6749a193d7fd8a
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.gem
10
+ /spec/lib/tmp
11
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ inherit_gem:
2
+ rubocop-shopify: rubocop.yml
3
+
4
+ Style/GlobalVars:
5
+ Enabled: false
6
+ Style/FrozenStringLiteralComment:
7
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rubocop'
6
+ gem 'rubocop-shopify', "~> 1.0.4", require: false
7
+
8
+ gem 'rspec'
9
+
10
+ gem 'nexus_cqrs'
11
+ gem 'pundit'
12
+ gem 'strings-case'
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nexus_cqrs_auth (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (6.0.3.3)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ zeitwerk (~> 2.2, >= 2.2.2)
15
+ ast (2.4.1)
16
+ concurrent-ruby (1.1.7)
17
+ diff-lcs (1.4.4)
18
+ i18n (1.8.5)
19
+ concurrent-ruby (~> 1.0)
20
+ minitest (5.14.2)
21
+ nexus_cqrs (0.0.13)
22
+ parallel (1.19.2)
23
+ parser (2.7.1.5)
24
+ ast (~> 2.4.1)
25
+ pundit (2.1.0)
26
+ activesupport (>= 3.0.0)
27
+ rainbow (3.0.0)
28
+ regexp_parser (1.8.1)
29
+ rexml (3.2.4)
30
+ rspec (3.9.0)
31
+ rspec-core (~> 3.9.0)
32
+ rspec-expectations (~> 3.9.0)
33
+ rspec-mocks (~> 3.9.0)
34
+ rspec-core (3.9.2)
35
+ rspec-support (~> 3.9.3)
36
+ rspec-expectations (3.9.2)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.9.0)
39
+ rspec-mocks (3.9.1)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.9.0)
42
+ rspec-support (3.9.3)
43
+ rubocop (0.89.1)
44
+ parallel (~> 1.10)
45
+ parser (>= 2.7.1.1)
46
+ rainbow (>= 2.2.2, < 4.0)
47
+ regexp_parser (>= 1.7)
48
+ rexml
49
+ rubocop-ast (>= 0.3.0, < 1.0)
50
+ ruby-progressbar (~> 1.7)
51
+ unicode-display_width (>= 1.4.0, < 2.0)
52
+ rubocop-ast (0.7.1)
53
+ parser (>= 2.7.1.5)
54
+ rubocop-shopify (1.0.5)
55
+ rubocop (~> 0.89.0)
56
+ ruby-progressbar (1.10.1)
57
+ strings-case (0.3.0)
58
+ thread_safe (0.3.6)
59
+ tzinfo (1.2.7)
60
+ thread_safe (~> 0.1)
61
+ unicode-display_width (1.7.0)
62
+ zeitwerk (2.4.0)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ nexus_cqrs
69
+ nexus_cqrs_auth!
70
+ pundit
71
+ rspec
72
+ rubocop
73
+ rubocop-shopify (~> 1.0.4)
74
+ strings-case
75
+
76
+ BUNDLED WITH
77
+ 1.17.2
@@ -0,0 +1 @@
1
+ nexus_cqrs_auth
@@ -0,0 +1,2 @@
1
+ require 'nexus_cqrs_auth/helper'
2
+ require 'nexus_cqrs_auth/middleware'
@@ -0,0 +1,16 @@
1
+ require 'pundit'
2
+
3
+ module NexusCqrsAuth
4
+ include Pundit
5
+ def authorize(command, record, query = nil, policy_class: nil)
6
+ query ||= Strings::Case.snakecase(command.demodularised_class_name) + '?'
7
+ @command_user = command.metadata[:current_user]
8
+ super_ = super(record, query, policy_class: policy_class)
9
+ @command_user = nil
10
+ super_
11
+ end
12
+
13
+ def pundit_user
14
+ @command_user || super
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ require 'nexus_cqrs'
2
+ require 'pundit'
3
+
4
+ # Authentication middleware for protecting commands/queries
5
+ module NexusCqrsAuth
6
+ class AuthMiddleware < ::NexusCqrs::BaseMiddleware
7
+ include NexusCqrsAuth
8
+
9
+ def call(message)
10
+ authorize(message, message, :authorise?)
11
+ @next.call(message)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module NexusCqrsAuth
2
+ VERSION = '0.0.0'
3
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'lib/nexus_cqrs_auth/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'nexus_cqrs_auth'
5
+ spec.version = NexusCqrsAuth::VERSION
6
+ spec.authors = ['Chris Harrison']
7
+ spec.email = ['chris.harrison@nexusmods.com']
8
+
9
+ spec.summary = 'Authorisation for the Nexus CQRS pattern'
10
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
11
+
12
+ # Specify which files should be added to the gem when it is released.
13
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
14
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
15
+ %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ end
17
+ spec.require_paths = ['lib']
18
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nexus_cqrs_auth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Harrison
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-09-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - chris.harrison@nexusmods.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - README.md
26
+ - lib/nexus_cqrs_auth.rb
27
+ - lib/nexus_cqrs_auth/helper.rb
28
+ - lib/nexus_cqrs_auth/middleware.rb
29
+ - lib/nexus_cqrs_auth/version.rb
30
+ - nexus_cqrs_auth.gemspec
31
+ homepage:
32
+ licenses: []
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.3.0
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.0.3
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Authorisation for the Nexus CQRS pattern
53
+ test_files: []