Skip to content

Commit bd14bb3

Browse files
committed
Move license compliance docs to installation
1 parent 0584c53 commit bd14bb3

1 file changed

Lines changed: 149 additions & 0 deletions

File tree

docs/pro/installation.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,155 @@ export REACT_ON_RAILS_PRO_LICENSE="your-license-token-here"
139139

140140
⚠️ **Security Warning**: Never commit your license token to version control. For production, use environment variables or secure secret management systems (Rails credentials, Heroku config vars, AWS Secrets Manager, etc.).
141141

142+
### License Validation Lifecycle
143+
144+
React on Rails Pro validates licenses offline with the public key embedded in the gem and node renderer package. There
145+
is no network call to ShakaCode during validation.
146+
147+
License validation happens in these places:
148+
149+
- Rails checks the license after application initialization and logs the result.
150+
- The standalone node renderer checks the license when the renderer master process starts and logs the result.
151+
- The browser receives `railsContext.rorPro` as a Pro-installed signal only; it does not validate the license.
152+
153+
A missing, expired, or invalid license does not prevent Rails or the node renderer from starting. In production, license
154+
issues are logged as warnings, and Rails includes an HTML attribution comment indicating the license state.
155+
156+
### Verify License Compliance
157+
158+
Use the built-in task as a deploy or release gate:
159+
160+
```bash
161+
RAILS_ENV=production bundle exec rake react_on_rails_pro:verify_license
162+
```
163+
164+
For CI/CD or scripting, request JSON output:
165+
166+
```bash
167+
RAILS_ENV=production FORMAT=json bundle exec rake react_on_rails_pro:verify_license
168+
```
169+
170+
The task exits with a non-zero status when the license is missing, invalid, or expired. It also reports
171+
`renewal_required: true` in JSON output when the license is expired or expiring within 30 days.
172+
173+
#### Blocking CI Example
174+
175+
Use a blocking CI check when an invalid license should stop a production deploy:
176+
177+
```yaml
178+
# .github/workflows/react-on-rails-pro-license.yml
179+
name: React on Rails Pro License
180+
181+
on:
182+
push:
183+
branches: [main]
184+
workflow_dispatch:
185+
186+
jobs:
187+
verify-license:
188+
runs-on: ubuntu-latest
189+
env:
190+
RAILS_ENV: production
191+
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE }}
192+
steps:
193+
- uses: actions/checkout@v4
194+
195+
- uses: ruby/setup-ruby@v1
196+
with:
197+
bundler-cache: true
198+
199+
- name: Verify React on Rails Pro license
200+
run: bundle exec rake react_on_rails_pro:verify_license
201+
```
202+
203+
#### Advisory CI Example
204+
205+
Use an advisory CI check when you want visibility without failing the workflow:
206+
207+
````yaml
208+
# .github/workflows/react-on-rails-pro-license-advisory.yml
209+
name: React on Rails Pro License Advisory
210+
211+
on:
212+
schedule:
213+
- cron: '0 15 * * 1'
214+
workflow_dispatch:
215+
216+
jobs:
217+
verify-license:
218+
runs-on: ubuntu-latest
219+
env:
220+
RAILS_ENV: production
221+
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE }}
222+
steps:
223+
- uses: actions/checkout@v4
224+
225+
- uses: ruby/setup-ruby@v1
226+
with:
227+
bundler-cache: true
228+
229+
- name: Check React on Rails Pro license
230+
run: |
231+
set +e
232+
output=$(bundle exec rake react_on_rails_pro:verify_license 2>&1)
233+
status=$?
234+
echo "$output"
235+
236+
{
237+
echo "## React on Rails Pro license"
238+
echo
239+
echo '```text'
240+
echo "$output"
241+
echo '```'
242+
} >> "$GITHUB_STEP_SUMMARY"
243+
244+
if [ "$status" -ne 0 ]; then
245+
echo "::warning title=React on Rails Pro license::License validation did not pass. See job summary."
246+
fi
247+
248+
exit 0
249+
````
250+
251+
Use either CI example in workflows where repository secrets are available, such as trusted branch pushes, scheduled jobs,
252+
manual runs, or deployment gates. Pull requests from public forks usually cannot access repository secrets, so these
253+
checks would report a missing token there.
254+
255+
### Monitor License Expiration
256+
257+
If your organization wants an app-owned scheduled check with a custom warning threshold, add a wrapper task like this:
258+
259+
```ruby
260+
# lib/tasks/react_on_rails_pro_license.rake
261+
namespace :licenses do
262+
desc "Fail if the React on Rails Pro license is invalid, expired, or expiring soon"
263+
task check_react_on_rails_pro: :environment do
264+
threshold_days = Integer(ENV.fetch("DAYS", "30"))
265+
info = ReactOnRailsPro::LicenseValidator.license_info
266+
status = info.fetch(:status)
267+
expiration = info[:expiration]
268+
days_remaining = expiration && ((expiration - Time.current) / 86_400).ceil
269+
270+
unless status == :valid
271+
abort "React on Rails Pro license is #{status}. Update REACT_ON_RAILS_PRO_LICENSE."
272+
end
273+
274+
if days_remaining && days_remaining <= threshold_days
275+
abort "React on Rails Pro license expires in #{days_remaining} days. Renew and rotate the key."
276+
end
277+
278+
message = "React on Rails Pro license is valid"
279+
message += " (#{days_remaining} days remaining)" if days_remaining
280+
puts message
281+
end
282+
end
283+
```
284+
285+
Run it from your scheduler or CI:
286+
287+
```bash
288+
RAILS_ENV=production DAYS=30 bundle exec rake licenses:check_react_on_rails_pro
289+
```
290+
142291
For complete license setup instructions, see [LICENSE_SETUP.md](https://github.com/shakacode/react_on_rails/blob/main/react_on_rails_pro/LICENSE_SETUP.md).
143292

144293
## Rails Configuration

0 commit comments

Comments
 (0)