@bigbinary/neeto-access-control-frontend 0.0.7 → 0.0.8
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.
- package/README.md +222 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1 +1,223 @@
|
|
|
1
1
|
# neeto-access-control-nano
|
|
2
|
+
|
|
3
|
+
The `neeto-access-control-nano` manages access control across neeto products. The nano exports the `@bigbinary/neeto-access-control-frontend` NPM package and `neeto-access-control-engine` Rails engine for development.
|
|
4
|
+
|
|
5
|
+
# Contents
|
|
6
|
+
|
|
7
|
+
1. [Development with Host Application](#development-with-host-application)
|
|
8
|
+
- [Engine](#engine)
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Frontend package](#frontend-package)
|
|
11
|
+
- [Installation](#installation-1)
|
|
12
|
+
- [Components](#components)
|
|
13
|
+
2. [Instructions for Publishing](#instructions-for-publishing)
|
|
14
|
+
3. [Releasing beta versions](#releasing-beta-versions)
|
|
15
|
+
|
|
16
|
+
# Development with Host Application
|
|
17
|
+
|
|
18
|
+
## Engine
|
|
19
|
+
|
|
20
|
+
The engine is used to manage access control across neeto products.
|
|
21
|
+
|
|
22
|
+
### Installation
|
|
23
|
+
|
|
24
|
+
1. Add the gem in `Gemfile`
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
source "NEETO_GEM_SERVER_URL" do
|
|
28
|
+
# ..existing gems
|
|
29
|
+
|
|
30
|
+
gem "neeto-access-control-engine"
|
|
31
|
+
end
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. Install the gem
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
bundle install
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. Add required migrations in the `db/migrate` folder.
|
|
41
|
+
Run the following commands to copy the migrations from the engine to the host application.
|
|
42
|
+
Ex: [neetoForm](https://github.com/bigbinary/neeto-form-web/blob/main/db/migrate/20240315162544_create_neeto_access_control_engine_configurations.neeto_access_control_engine.rb)
|
|
43
|
+
|
|
44
|
+
```shell
|
|
45
|
+
bundle exec rails neeto_access_control_engine:install:migrations
|
|
46
|
+
bundle exec rails db:migrate
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
4. Add this line to your application's `config/routes.rb` file:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
mount NeetoAccessControlEngine::Engine => "/secure"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
5. Add `has_one` association to the model you want to add the access control configuration.
|
|
56
|
+
For Example - The organization only needs single access control.
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
class Organization < ApplicationRecord
|
|
60
|
+
has_one :access_control_configuration, as: :owner, class_name: "NeetoAccessControlEngine::Configuration", dependent: :destroy
|
|
61
|
+
end
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
6. Your controller must include the concern and access_control_configuration method.
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
class PublicController < ApplicationController
|
|
68
|
+
.
|
|
69
|
+
.
|
|
70
|
+
include NeetoAccessControlEngine::Authenticate
|
|
71
|
+
.
|
|
72
|
+
private
|
|
73
|
+
|
|
74
|
+
def access_control_configuration
|
|
75
|
+
@_access_control_configuration ||= @organization.access_control_configuration
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
7. Add overrides for the following files:
|
|
81
|
+
|
|
82
|
+
- 7.1. google_controller_override.rb
|
|
83
|
+
|
|
84
|
+
```ruby
|
|
85
|
+
NeetoAccessControlEngine::GoogleController.class_eval do
|
|
86
|
+
private
|
|
87
|
+
|
|
88
|
+
def access_control_configuration
|
|
89
|
+
@_access_control_configuration ||= @organization.access_control_configuration
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- 7.2. guest_sessions_controller_override.rb
|
|
95
|
+
|
|
96
|
+
```ruby
|
|
97
|
+
NeetoAccessControlEngine::GuestSessionsController.class_eval do
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
def access_control_configuration
|
|
101
|
+
@_access_control_configuration ||= @organization.access_control_configuration
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- 7.3. configurations_controller_override.rb
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
NeetoAccessControlEngine::Api::V1::ConfigurationsController.class_eval do
|
|
110
|
+
|
|
111
|
+
private
|
|
112
|
+
|
|
113
|
+
def owner
|
|
114
|
+
@organization
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
8. Add Google OAuth support
|
|
120
|
+
|
|
121
|
+
- 8.1. Create Google OAuth account
|
|
122
|
+
[Watch the demo video](https://sandip-mane.neetorecord.com/watch/2bf5c48e-9fce-4eef-a225-21b9ea6b3a33) for step-by-step instructions on creating a Google OAuth account.
|
|
123
|
+
Add the authorised redirect URI: `https://connect.neetokb.net/secure/google_oauth2/callback`
|
|
124
|
+
|
|
125
|
+
- 8.2. Set the env variables
|
|
126
|
+
Add the following secret values to `config/secrets.yml`.
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
google:
|
|
130
|
+
client_id: <%= ENV['GOOGLE_OAUTH_CLIENT_ID'] %>
|
|
131
|
+
client_secret: <%= ENV['GOOGLE_OAUTH_CLIENT_SECRET'] %>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Frontend package
|
|
135
|
+
|
|
136
|
+
### Installation
|
|
137
|
+
|
|
138
|
+
1. Install the latest `neeto-access-control-frontend` package using the below command:
|
|
139
|
+
```zsh
|
|
140
|
+
yarn add @bigbinary/neeto-access-control-frontend
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Components
|
|
144
|
+
|
|
145
|
+
#### 1. `Configuration` ([source code](/app/javascript/src/components/Configuration/index.jsx))
|
|
146
|
+
|
|
147
|
+
**Props**
|
|
148
|
+
|
|
149
|
+
- `ownerId`: To specify the ID of the instance of the model. The ID is used to fetch and update access control configuration.
|
|
150
|
+
- `ownerType`: Type of the model.
|
|
151
|
+
- `onReset`: Callback function that is triggered when the reset button is clicked.
|
|
152
|
+
- `onSuccess`: Callback function that is triggered when the configuration is successfully updated.
|
|
153
|
+
- `handleCancel`: Callback function that is triggered when the cancel button is clicked.
|
|
154
|
+
- `headerProps`: Props passed to the [`Header`](https://neeto-molecules.neeto.com/?path=/docs/layouts-header--docs) component from neetoMolecules.
|
|
155
|
+
- `className`: Additional classes to be added to the form.
|
|
156
|
+
|
|
157
|
+
**Usage**
|
|
158
|
+
|
|
159
|
+
This is an example usage in neetoKB
|
|
160
|
+
|
|
161
|
+
```jsx
|
|
162
|
+
import React from "react";
|
|
163
|
+
|
|
164
|
+
import { Configuration } from "@bigbinary/neeto-access-control-frontend";
|
|
165
|
+
|
|
166
|
+
import { HELP_SECURITY_DOC_URL } from "src/constants/urls";
|
|
167
|
+
|
|
168
|
+
import { buildDefaultBreadcrumbs } from "./utils";
|
|
169
|
+
|
|
170
|
+
const AccessControl = () => {
|
|
171
|
+
return (
|
|
172
|
+
<Configuration
|
|
173
|
+
className="mx-auto max-w-3xl md:px-0 lg:px-6"
|
|
174
|
+
handleCancel={() => {}}
|
|
175
|
+
headerProps={{
|
|
176
|
+
title: "Access control",
|
|
177
|
+
description: "Access control description",
|
|
178
|
+
helpLink: HELP_SECURITY_DOC_URL,
|
|
179
|
+
breadcrumbs: buildDefaultBreadcrumbs({
|
|
180
|
+
title: "Access control",
|
|
181
|
+
}),
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export default AccessControl;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Customize option labels in the host application with translations
|
|
191
|
+
|
|
192
|
+
To customize option labels for authentication, you can set the translations from the host application.
|
|
193
|
+
To set the translations from the host application:
|
|
194
|
+
- Open the `en.json` file.
|
|
195
|
+
- Add translations for the auth option labels under the `neetoAccessControl.auth` namespace.
|
|
196
|
+
For Example:
|
|
197
|
+
```js
|
|
198
|
+
{
|
|
199
|
+
"neetoAccessControl": {
|
|
200
|
+
"auth": {
|
|
201
|
+
"no": "No auth label",
|
|
202
|
+
"basic": "Basic auth label",
|
|
203
|
+
"email": "Email auth label"
|
|
204
|
+
"session": "Session auth label"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
# Instructions for Publishing
|
|
211
|
+
|
|
212
|
+
Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
|
|
213
|
+
|
|
214
|
+
# Releasing beta versions
|
|
215
|
+
|
|
216
|
+
- Push the changes to a target branch for releasing the beta version.
|
|
217
|
+
- Update the package version to `{latest-version}-beta` (if `1.2.34` is the current latest version, it will be `1.2.34-beta`) in the target branch for beta release.
|
|
218
|
+
- [Draft a new release](https://github.com/bigbinary/neeto-access-control-nano/releases/new) from the repo with the target branch.
|
|
219
|
+
- Add a new tag and title in the format: version prefixed with `v`, eg: `v1.2.34-beta`.
|
|
220
|
+
- Generate release notes.
|
|
221
|
+
- Set the release as a pre-release and publish the release.
|
|
222
|
+
|
|
223
|
+
If we are releasing a beta version of a product, we have to inform the compliance team as well to avoid overwriting the version with the latest version on the next compliance release.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-access-control-frontend",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Neeto access control",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://github.com/bigbinary/neeto-access-control-nano",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"@babel/preset-typescript": "7.23.2",
|
|
49
49
|
"@babel/runtime": "7.23.2",
|
|
50
50
|
"@bigbinary/babel-preset-neeto": "1.0.6",
|
|
51
|
-
"@bigbinary/eslint-plugin-neeto": "1.5.
|
|
51
|
+
"@bigbinary/eslint-plugin-neeto": "1.5.1",
|
|
52
52
|
"@bigbinary/neeto-audit-frontend": "2.0.9",
|
|
53
53
|
"@bigbinary/neeto-cist": "1.0.9",
|
|
54
|
-
"@bigbinary/neeto-commons-frontend": "3.
|
|
54
|
+
"@bigbinary/neeto-commons-frontend": "3.4.0",
|
|
55
55
|
"@bigbinary/neeto-filters-frontend": "3.3.1",
|
|
56
56
|
"@bigbinary/neeto-icons": "1.18.4",
|
|
57
57
|
"@bigbinary/neeto-molecules": "1.15.15",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
},
|
|
154
154
|
"peerDependencies": {
|
|
155
155
|
"@bigbinary/neeto-cist": "latest",
|
|
156
|
-
"@bigbinary/neeto-commons-frontend": "3.
|
|
156
|
+
"@bigbinary/neeto-commons-frontend": "3.4.0",
|
|
157
157
|
"@bigbinary/neeto-editor": "^1.26.3",
|
|
158
158
|
"@bigbinary/neeto-filters-frontend": "3.3.1",
|
|
159
159
|
"@bigbinary/neeto-icons": "1.18.4",
|