access_forge-permissions 0.1.2 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa5e73556453d6a607b119e7940db5ead024c7c413b4d63e37826f9b0f055656
4
- data.tar.gz: cdc6ee945f57ebbe35e285e484291b9a5ab2ffb4608275f3ebecc6c18f4ba671
3
+ metadata.gz: 19d6c062402c02a718432846522854cdcf43a94573010561b1fb8b5af9da9eb7
4
+ data.tar.gz: fa77e771842712439cd55f2fc64c0e71447ef078e81612ef1fe7ff3d5bf8246a
5
5
  SHA512:
6
- metadata.gz: dedbf211e66502050166bcfb00a881b92ef68371d149b16cc1c9484c7597a684a69b4ffe3f87dc575db1338eba805e4a7c09f55fe525a5126afdcb8835141f26
7
- data.tar.gz: 32bae7dad9bf20c24b73875d427344c30c414d2d1fee5456ca689c497a67efbb5176b750e12b1e04832ae4e1e14969f94d6bc82894d4ce22041d81047d8b678f
6
+ metadata.gz: 6f40baae5c31e3aa1fd0c01c197e536835d9d28e7668836da10fe91e90997e3ae825a9ec5140d694e28c31b6b0eb228d08e1f2ce9e4122121feb9e01fc63a76c
7
+ data.tar.gz: c1549bf8677eab2973aad6a5aae743af225c13f488f682c219e482c7fb8b9b96da8f98d75989aa830dae21c867315759ff3dd578f0a3ca7f4d82599bba25010f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- access_forge-permissions (0.1.2)
4
+ access_forge-permissions (1.0.0)
5
5
  rails (>= 6.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,38 +1,195 @@
1
1
  # AccessForge::Permissions
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/access_forge/permissions`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ `AccessForge::Permissions` provides a production-ready `PermissionPolicyRule` for **Ruby on Rails** applications using AccessForge.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ It introduces a simple, composable way to express permission-based authorization - without imposing a fixed persistence model.
6
6
 
7
- ## Installation
7
+ If you are using AccessForge and want permission checks backed by your own data model, this is the first extension you should reach for.
8
+
9
+ ## Philosophy
10
+
11
+ AccessForge defines how policies are evaluated.
12
+
13
+ AccessForge::Permissions defines a reusable rule for permission checks.
8
14
 
9
- Add this line to your application's Gemfile:
15
+ This gem deliberately keeps its contract minimal:
10
16
 
17
+ If your `User` has a `has_many :permissions` association, `PermissionPolicyRule` will work.
18
+
19
+ That’s it.
20
+
21
+ How permissions are assigned - directly, via groups, or through any other structure - is entirely up to you.
22
+
23
+ ## Installation
24
+
25
+ Add to your Gemfile:
11
26
  ```ruby
12
- gem 'access_forge-permissions'
27
+ gem "access_forge-permissions"
28
+ ```
29
+
30
+ Then:
31
+ ```bash
32
+ bundle install
33
+ ```
34
+
35
+ ## The Core Rule: `PermissionPolicyRule`
36
+
37
+ `PermissionPolicyRule` checks whether the current user has a required permission.
38
+
39
+ It expects:
40
+ * A `User` model
41
+ * A `has_many :permissions` association on that model
42
+
43
+ Example:
44
+ ```
45
+ class User < ApplicationRecord
46
+ has_many :permissions
47
+ end
48
+ ```
49
+
50
+ Or via has_many :through:
51
+ ```
52
+ class User < ApplicationRecord
53
+ has_many :access_group_users
54
+ has_many :access_groups, through: :access_group_users
55
+ has_many :permissions, through: :access_groups
56
+ end
57
+ ```
58
+
59
+ ## Usage with AccessForge
60
+
61
+ Inside your AccessForge policy:
62
+ ```
63
+ class EmployeePolicy < AccessForge::Policy
64
+ def index?
65
+ authorized?(
66
+ [ PermissionPolicyRule ],
67
+ { feature: 'Employees', verb: :read }
68
+ )
69
+ end
70
+ end
71
+ ```
72
+
73
+ When evaluated, the rule checks:
74
+ ```
75
+ current_user.permissions.exists?({ permissions: { name: "Can #{options[:verb]} #{options[:feature]}" } })
76
+ ```
77
+
78
+ If the permission exists, the rule passes.
79
+
80
+ If not, authorization fails.
81
+
82
+ Because it is a rule object, it composes naturally with other AccessForge rules.
83
+
84
+ ## Flexible Data Models
85
+
86
+ This gem does **not** enforce a particular authorization architecture.
87
+
88
+ You may:
89
+ * Assign permissions directly to users
90
+ * Implement group-based RBAC
91
+ * Build hierarchical group structures
92
+ * Introduce multi-tenant permission scoping
93
+ * Extend the Permission model with metadata
94
+
95
+ The only requirement is that the user responds to:
13
96
  ```
97
+ user.permissions
98
+ ```
99
+
100
+ This design keeps your authorization model:
101
+ * Explicit
102
+ * Evolvable
103
+ * Aligned with your domain
104
+
105
+ ## Access Group Generator
106
+
107
+ To help you get started, this gem includes a generator that creates a conventional group-based permission structure.
108
+
109
+ Run:
110
+ ```bash
111
+ rails generate access_forge:access_groups
112
+ ```
113
+
114
+ This creates:
115
+ * AccessGroup
116
+ * AccessGroupUser
117
+ * AccessGroupPermission
118
+ * Permission
119
+
120
+ Along with their corresponding migrations.
121
+
122
+ The generated structure provides:
123
+ * Many-to-many Users ↔ AccessGroups
124
+ * Many-to-many AccessGroups ↔ Permissions
125
+ * A `has_many :permissions, through:` setup on `User`
14
126
 
15
- And then execute:
127
+ You are free to modify or extend these models after generation.
16
128
 
17
- $ bundle
129
+ The generator exists for convenience - not constraint.
18
130
 
19
- Or install it yourself as:
131
+ ## Why This Design?
20
132
 
21
- $ gem install access_forge-permissions
133
+ Many authorization libraries tightly couple:
134
+ * Policy logic
135
+ * Persistence model
136
+ * DSL assumptions
22
137
 
23
- ## Usage
138
+ `AccessForge::Permissions` intentionally separates these concerns.
139
+ * AccessForge evaluates policies.
140
+ * PermissionPolicyRule checks permissions.
141
+ * Your application owns the data model.
24
142
 
25
- TODO: Write usage instructions here
143
+ This separation provides:
144
+ * Architectural control
145
+ * Testable rule objects
146
+ * Clear domain boundaries
147
+ * Long-term flexibility
148
+
149
+ ## When to Use This Extension
150
+
151
+ Use `AccessForge::Permissions` if:
152
+ * You want permission-based authorization
153
+ * You prefer explicit policy objects over implicit callbacks
154
+ * You want full control over your persistence model
155
+ * You are building a system where authorization must evolve over time
156
+
157
+ ## Relationship to AccessForge
158
+
159
+ AccessForge is a controller-oriented policy engine built for experienced Rails developers who value architectural control.
160
+
161
+ `AccessForge::Permissions` is the first official extension — providing a clean, composable permission rule that integrates seamlessly into the core engine.
162
+
163
+ Together they provide:
164
+ * Explicit controller authorization
165
+ * Composable rule objects
166
+ * Flexible persistence strategies
167
+ * Clear separation of concerns
26
168
 
27
169
  ## Development
28
170
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
171
+ After checking out the repository:
172
+ ```
173
+ bin/setup
174
+ rake spec
175
+ ```
176
+
177
+ To release a new version:
178
+ 1. Update the version number in `version.rb`
179
+ 2. Run:
180
+ ```
181
+ bundle exec rake release
182
+ ```
30
183
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
184
+ This will tag the release, push commits, and publish the gem to RubyGems.
32
185
 
33
186
  ## Contributing
34
187
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/access_forge-permissions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
188
+ Bug reports and pull requests are welcome on GitHub:
189
+
190
+ [https://github.com/CodeTectonics/access_forge-permissions](https://github.com/CodeTectonics/access_forge-permissions).
191
+
192
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/CodeTectonics/access_forge-permissions/blob/main/CODE_OF_CONDUCT.md).
36
193
 
37
194
  ## License
38
195
 
@@ -40,4 +197,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
197
 
41
198
  ## Code of Conduct
42
199
 
43
- Everyone interacting in the AccessForge::Permissions projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/access_forge-permissions/blob/master/CODE_OF_CONDUCT.md).
200
+ Everyone interacting in the AccessForge project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/CodeTectonics/access_forge-permissions/blob/main/CODE_OF_CONDUCT.md).
201
+
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Mark Harbison"]
9
9
  spec.email = ["mark@tyne-solutions.com"]
10
10
 
11
- spec.summary = "A persistence-backed AccessForge implementation for permission based authorisation."
12
- spec.description = "A persistence-backed AccessForge implementation for permission based authorisation."
11
+ spec.summary = "The official permission layer for AccessForge."
12
+ spec.description = "The official permission layer for AccessForge."
13
13
  spec.homepage = "https://github.com/CodeTectonics/access_forge-permissions"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 3.2.0"
@@ -1,5 +1,5 @@
1
1
  module AccessForge
2
2
  module Permissions
3
- VERSION = "0.1.2"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: access_forge-permissions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Harbison
@@ -66,8 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.21'
69
- description: A persistence-backed AccessForge implementation for permission based
70
- authorisation.
69
+ description: The official permission layer for AccessForge.
71
70
  email:
72
71
  - mark@tyne-solutions.com
73
72
  executables: []
@@ -127,7 +126,7 @@ requirements: []
127
126
  rubygems_version: 3.4.19
128
127
  signing_key:
129
128
  specification_version: 4
130
- summary: A persistence-backed AccessForge implementation for permission based authorisation.
129
+ summary: The official permission layer for AccessForge.
131
130
  test_files:
132
131
  - spec/access_forge/permissions_spec.rb
133
132
  - spec/spec_helper.rb