https://github.com/warrant-dev/warrant-ruby
Ruby SDK for Warrant
https://github.com/warrant-dev/warrant-ruby
abac access-control acl attribute-based-access-control authorization authz permissions rbac role-based-access-control ruby
Last synced: 3 months ago
JSON representation
Ruby SDK for Warrant
- Host: GitHub
- URL: https://github.com/warrant-dev/warrant-ruby
- Owner: warrant-dev
- License: mit
- Created: 2021-11-15T17:46:46.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-03T19:09:04.000Z (about 1 year ago)
- Last Synced: 2025-03-27T11:38:35.497Z (3 months ago)
- Topics: abac, access-control, acl, attribute-based-access-control, authorization, authz, permissions, rbac, role-based-access-control, ruby
- Language: Ruby
- Homepage:
- Size: 171 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Warrant Ruby Library
Use [Warrant](https://warrant.dev/) in ruby projects.
[](https://badge.fury.io/rb/warrant)
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'warrant'
```And then execute:
$ bundle install
Or install it yourself:
$ gem install warrant
You can also build the gem from source:
$ gem build warrant.gemspec
## Documentation
- [Ruby API Docs](https://rubydoc.info/gems/warrant)
- [Warrant Docs](https://docs.warrant.dev/)## Requirements
- Ruby 2.3+.
## Usage
```ruby
require 'warrant'
Warrant.api_key = 'api_test_f5dsKVeYnVSLHGje44zAygqgqXiLJBICbFzCiAg1E='# Create a user
Warrant::User.create(user_id: "user123")# Check whether user slp951 has view access to report 7asm24
Warrant::Warrant.is_authorized?(object_type: "report", object_id: "7asm24", relation: "viewer", subject: { object_id: "user", object_id: "slp951" })
```## Configuring the API and Authorize Endpoints
The API and Authorize endpoints the SDK makes requests to is configurable via the `Warrant.api_base` and `Warrant.authorize_endpoint` attributes:```ruby
require 'warrant'# Set api and authorize endpoints to http://localhost:8000
Warrant.api_base = 'http://localhost:8000'
Warrant.authorize_endpoint = 'http://localhost:8000'
```## Configuring SSL
By default, the SDK will attempt to use SSL when making requests to the API. This setting is configurable via the `Warrant.use_ssl` attribute:```ruby
require 'warrant'# Disable ssl
Warrant.use_ssl = false
```We’ve used a random API key in these code examples. Replace it with your [actual publishable API keys](https://app.warrant.dev) to
test this code through your own Warrant account.For more information on how to use the Warrant API, please refer to the [Warrant API reference](https://docs.warrant.dev).
Note that we may release new [minor and patch](https://semver.org/) versions of this library with small but backwards-incompatible fixes to the type declarations. These changes will not affect Warrant itself.