Project

warrant

0.0
The project is in a healthy, maintained state
Ruby library for the Warrant API at https://warrant.dev.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Warrant Ruby Library

Use Warrant in ruby projects.

Gem Version Slack

Installation

Add this line to your application's Gemfile:

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

Requirements

  • Ruby 2.3+.

Usage

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:

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:

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 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.

Note that we may release new minor and patch versions of this library with small but backwards-incompatible fixes to the type declarations. These changes will not affect Warrant itself.