Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e212492
Add offline JWT-based license validation system for React on Rails Pro
AbanoubGhadban Oct 8, 2025
e10775b
Add React on Rails Pro license file to .gitignore in multiple locations
AbanoubGhadban Oct 13, 2025
0d4c982
add needed licence rake tasks
AbanoubGhadban Oct 9, 2025
0f34eb2
Require exp field in license validation
AbanoubGhadban Oct 12, 2025
2f4a185
Add tests for required exp field validation
AbanoubGhadban Oct 12, 2025
4d6fe51
Require valid license in all environments (dev, test, prod)
AbanoubGhadban Oct 12, 2025
570b01b
Add license validation on startup for both Rails and Node renderer
AbanoubGhadban Oct 12, 2025
ea79463
Change license field from 'license_type' to 'plan' and add 'issued_by…
AbanoubGhadban Oct 12, 2025
c0586c1
Remove obsolete license key file from the dummy config
AbanoubGhadban Oct 12, 2025
76edca3
Add React on Rails Pro license file to .gitignore and Gemfile.lock
AbanoubGhadban Oct 12, 2025
5b74c1e
Fix require statement in license validator spec to use spec_helper
AbanoubGhadban Oct 12, 2025
7f2f088
update yarn.lock
AbanoubGhadban Oct 12, 2025
8f8e88c
Fix license validator spec by stubbing Rails.logger and Rails.root
AbanoubGhadban Oct 12, 2025
9650099
Fix Node.js license validator tests and disable auto-expiration check
AbanoubGhadban Oct 12, 2025
b11a3d9
Remove react_on_rails_pro_licence_valid? and consolidate to react_on_…
AbanoubGhadban Oct 13, 2025
7beeb5c
Make react_on_rails_pro? actively validate license and remove backwar…
AbanoubGhadban Oct 13, 2025
5deee18
Remove redundant 'before: :load_config_initializers' hook from licens…
AbanoubGhadban Oct 13, 2025
3e01f71
Rename validation methods to use ! convention for exception-throwing
AbanoubGhadban Oct 13, 2025
fed1c36
Update license public key documentation and source URL
AbanoubGhadban Oct 13, 2025
38ef270
Refactor license validation to remove unnecessary conditional logging
AbanoubGhadban Oct 13, 2025
5d6514f
Refactor LicensePublicKey module documentation for clarity and consis…
AbanoubGhadban Oct 13, 2025
ab9801c
Refactor LicenseValidator to simplify validation logic and remove unn…
AbanoubGhadban Oct 13, 2025
fca96e4
Refactor Node.js license validator from singleton class to functional…
AbanoubGhadban Oct 13, 2025
9299a24
Enhance license data structure and improve security in license valida…
AbanoubGhadban Oct 13, 2025
27e585c
Refactor validateLicense to void function for clearer API semantics
AbanoubGhadban Oct 13, 2025
37704eb
Enhance public key update task with local URL handling and add usage …
AbanoubGhadban Oct 13, 2025
4a895c2
Enhance ReactOnRailsHelper spec by mocking additional utility methods…
AbanoubGhadban Oct 13, 2025
6bd6eda
Enhance pro features context by allowing multiple message stubs for i…
AbanoubGhadban Oct 13, 2025
e1f167d
Enhance pro features context by adding support for RSC in immediate h…
AbanoubGhadban Oct 13, 2025
05739bb
fix TS problems
AbanoubGhadban Oct 13, 2025
9626ff2
Enhance license validation test by generating a separate key pair for…
AbanoubGhadban Oct 13, 2025
118b9f1
Refactor license claims in JWT to use standard 'iss' identifier and u…
AbanoubGhadban Oct 14, 2025
05b8615
Implement license expiration handling with a 1-month grace period for…
AbanoubGhadban Oct 14, 2025
278b8dc
Add license attribution comment and refactor license validation metho…
AbanoubGhadban Oct 14, 2025
5555b37
Refactor license validation methods to use 'validated_license_data!' …
AbanoubGhadban Oct 15, 2025
58d680e
Add tests for react_on_rails_attribution_comment to verify Pro and op…
AbanoubGhadban Oct 15, 2025
765cde1
Add tests for Pro and open source attribution comments in rendered ou…
AbanoubGhadban Oct 15, 2025
cf975c7
Add tests for single attribution comment inclusion in React on Rails …
AbanoubGhadban Oct 15, 2025
e480515
Refactor license evaluation logic and improve error handling for miss…
AbanoubGhadban Oct 15, 2025
8b49a7a
Remove unnecessary setup in pro_attribution_comment tests for cleaner…
AbanoubGhadban Oct 15, 2025
b63a704
Stub ReactOnRailsPro::Utils.pro_attribution_comment for consistent te…
AbanoubGhadban Oct 15, 2025
b9c0c5b
Update tests to expect HTML comments instead of script tags for React…
AbanoubGhadban Oct 15, 2025
125b364
Stub ReactOnRailsPro::Utils.pro_attribution_comment for consistent te…
AbanoubGhadban Oct 15, 2025
895d92a
Update documentation to clarify license usage and add HTML comment at…
AbanoubGhadban Oct 15, 2025
d5b43a0
Refactor license validation logic to use getValidatedLicenseData and …
AbanoubGhadban Oct 15, 2025
b083a65
Update grace period message format to use "day(s)" for consistency in…
AbanoubGhadban Oct 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th

Changes since the last non-beta release.

#### Added

- **Attribution Comment**: Added HTML comment attribution to Rails views containing React on Rails functionality. The comment automatically displays which version is in use (open source React on Rails or React on Rails Pro) and, for Pro users, shows the license status. This helps identify React on Rails usage across your application. [PR #1857](https://github.com/shakacode/react_on_rails/pull/1857) by [AbanoubGhadban](https://github.com/AbanoubGhadban).

#### Breaking Changes

- **React on Rails Core Package**: Several Pro-only methods have been removed from the core package and are now exclusively available in the `react-on-rails-pro` package. If you're using any of the following methods, you'll need to migrate to React on Rails Pro:
Expand Down Expand Up @@ -65,7 +69,7 @@ To migrate to React on Rails Pro:
import ReactOnRails from 'react-on-rails-pro';
```

4. If you're using a free license for personal (non-production) use, you can obtain one at [React on Rails Pro License](https://www.shakacode.com/react-on-rails-pro). The Pro package is free for personal, educational, and non-production usage.
4. If you're using a free license, you can obtain one at [React on Rails Pro License](https://www.shakacode.com/react-on-rails-pro). **Important: The free 3-month evaluation license is intended for personal, educational, and evaluation purposes only. It should NOT be used for production deployments.** Production use requires a paid license.

**Note:** If you're not using any of the Pro-only methods listed above, no changes are required.

Expand Down
21 changes: 17 additions & 4 deletions lib/react_on_rails/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,23 @@ def rails_context_if_not_already_rendered

@rendered_rails_context = true

content_tag(:script,
json_safe_and_pretty(data).html_safe,
type: "application/json",
id: "js-react-on-rails-context")
attribution_comment = react_on_rails_attribution_comment
script_tag = content_tag(:script,
json_safe_and_pretty(data).html_safe,
type: "application/json",
id: "js-react-on-rails-context")

"#{attribution_comment}\n#{script_tag}".html_safe
end

# Generates the HTML attribution comment
# Pro version calls ReactOnRailsPro::Utils for license-specific details
def react_on_rails_attribution_comment
if ReactOnRails::Utils.react_on_rails_pro?
ReactOnRailsPro::Utils.pro_attribution_comment
else
"<!-- Powered by React on Rails (c) ShakaCode | Open Source -->"
end
end

# prepend the rails_context if not yet applied
Expand Down
4 changes: 2 additions & 2 deletions lib/react_on_rails/pro_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module ProUtils
PRO_ONLY_OPTIONS = %i[immediate_hydration].freeze

# Checks if React on Rails Pro features are available
# @return [Boolean] true if Pro license is valid, false otherwise
# @return [Boolean] true if Pro is installed and licensed, false otherwise
def self.support_pro_features?
ReactOnRails::Utils.react_on_rails_pro_licence_valid?
ReactOnRails::Utils.react_on_rails_pro?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react_on_rails_pro_licence_valid? has been removed, as the app should not start unless the license is valid. Therefore, react_on_rails_pro? now checks for license validation.

end

def self.disable_pro_render_options_if_not_licensed(raw_options)
Expand Down
27 changes: 10 additions & 17 deletions lib/react_on_rails/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,19 @@ def self.gem_available?(name)
end
end

# Todo -- remove this for v13, as we don't need both boolean and number
# Checks if React on Rails Pro is installed and licensed.
# This method validates the license and will raise an exception if invalid.
#
# @return [Boolean] true if Pro is available with valid license
# @raise [ReactOnRailsPro::Error] if license is invalid
def self.react_on_rails_pro?
return @react_on_rails_pro if defined?(@react_on_rails_pro)

@react_on_rails_pro = gem_available?("react_on_rails_pro")
@react_on_rails_pro = begin
return false unless gem_available?("react_on_rails_pro")

ReactOnRailsPro::Utils.validated_license_data!.present?
end
end

# Return an empty string if React on Rails Pro is not installed
Expand All @@ -246,21 +254,6 @@ def self.react_on_rails_pro_version
end
end

def self.react_on_rails_pro_licence_valid?
return @react_on_rails_pro_licence_valid if defined?(@react_on_rails_pro_licence_valid)

@react_on_rails_pro_licence_valid = begin
return false unless react_on_rails_pro?

# Maintain compatibility with legacy versions of React on Rails Pro:
# Earlier releases did not require license validation, as they were distributed as private gems.
# This check ensures that the method works correctly regardless of the installed version.
return true unless ReactOnRailsPro::Utils.respond_to?(:licence_valid?)

ReactOnRailsPro::Utils.licence_valid?
end
end

def self.rsc_support_enabled?
return false unless react_on_rails_pro?

Expand Down
3 changes: 3 additions & 0 deletions react_on_rails_pro/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ yalc.lock

# File Generated by ROR FS-based Registry
**/generated

# React on Rails Pro License Key
config/react_on_rails_pro_license.key
1 change: 1 addition & 0 deletions react_on_rails_pro/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ You can find the **package** version numbers from this repo's tags and below in

### Added
- Added `cached_stream_react_component` helper method, similar to `cached_react_component` but for streamed components.
- **License Validation System**: Implemented comprehensive JWT-based license validation with offline verification using RSA-256 signatures. License validation occurs at startup in both Ruby and Node.js environments. Supports required fields (`sub`, `iat`, `exp`) and optional fields (`plan`, `organization`, `iss`). FREE evaluation licenses are available for 3 months at [shakacode.com/react-on-rails-pro](https://shakacode.com/react-on-rails-pro). [PR #1857](https://github.com/shakacode/react_on_rails/pull/1857) by [AbanoubGhadban](https://github.com/AbanoubGhadban).

### Changed (Breaking)
- `config.prerender_caching`, which controls caching for non-streaming components, now also controls caching for streamed components. To disable caching for an individual render, pass `internal_option(:skip_prerender_cache)`.
Expand Down
Loading
Loading