Coder Social home page Coder Social logo

authzed / authzed-rb Goto Github PK

View Code? Open in Web Editor NEW
15.0 5.0 11.0 196 KB

Official SpiceDB client library for Ruby

Home Page: https://docs.authzed.com/reference/api

License: Apache License 2.0

Ruby 100.00%
ruby permissions authorization authzed sdk zanzibar spicedb spicedb-client authzed-client fine-grained-authorization

authzed-rb's Introduction

Authzed Ruby Client

Ruby Gems Docs License Build Status Discord Server Twitter

This repository houses the official Ruby client library for Authzed and SpiceDB.

SpiceDB is a database system for managing security-critical permissions checking.

SpiceDB acts as a centralized service that stores authorization data. Once stored, data can be performantly queried to answer questions such as "Does this user have access to this resource?" and "What are all the resources this user has access to?".

Authzed operates the globally available, serverless database platform for SpiceDB.

Supported client API versions:

You can find more info about the API in the Authzed Documentation API Reference or the Authzed API Buf Registry repository.

See CONTRIBUTING.md for instructions on how to contribute and perform common tasks like building the project and running tests.

Getting Started

We highly recommend following the Protecting Your First App guide to learn the latest best practice to integrate an application with Authzed.

If you're interested in example uses of the API, see the spec files in the spec directory.

Basic Usage

Installation

This project is packaged as the gem authzed on Ruby Gems.

The command to install the library is:

gem install authzed

Initializing a client

In order to successfully connect, you will have to provide a Bearer Token with your own API Token from the Authzed dashboard in place of t_your_token_here_1234567deadbeef in the following example:

require 'authzed'


client = Authzed::Api::V1::Client.new(
    target: "localhost:50051",
    credentials: :this_channel_is_insecure,
    interceptors: [Authzed::GrpcUtil::BearerToken.new(token: "somerandomkeyhere")],
)

Performing an API call

require 'authzed'

# Is Emilia in the set of users that can read post #1?
resp = client.permissions_service.check_permission(
  Authzed::Api::V1::CheckPermissionRequest.new(
    consistency: Authzed::Api::V1::Consistency.new(
      at_least_as_fresh: Authzed::Api::V1::ZedToken.new(token: zed_token)
    ),
    resource: Authzed::Api::V1::ObjectReference.new(object_type: 'blog/post', object_id: '1'),
    permission: 'read',
    subject: Authzed::Api::V1::SubjectReference.new(
      object: Authzed::Api::V1::ObjectReference.new(object_type: 'blog/user', object_id: 'emilia')
    )
  )
)
can_read = Authzed::Api::V1::CheckPermissionResponse::Permissionship.resolve(resp.permissionship) ==
  Authzed::Api::V1::CheckPermissionResponse::Permissionship::PERMISSIONSHIP_HAS_PERMISSION

authzed-rb's People

Contributors

authzedbot avatar dependabot[bot] avatar dweinand avatar josephschorr avatar jzelinskie avatar samkim avatar stevendaniels avatar vroldanbet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

authzed-rb's Issues

Protobuf import path issue

Warning: Protobuf detected an import path issue while loading generated file /usr/local/rvm/gems/ruby-3.1.4/gems/authzed-0.7.0/lib/authzed/api/v1/core_pb.rb
Each proto file must use a consistent fully-qualified name.
This will become an error in the next major version.
Warning: Protobuf detected an import path issue while loading generated file /usr/local/rvm/gems/ruby-3.1.4/gems/authzed-0.7.0/lib/authzed/api/v1/schema_service_pb.rb
Each proto file must use a consistent fully-qualified name.
This will become an error in the next major version.
Warning: Protobuf detected an import path issue while loading generated file /usr/local/rvm/gems/ruby-3.1.4/gems/authzed-0.7.0/lib/authzed/api/v1/watch_service_pb.rb
Each proto file must use a consistent fully-qualified name.
This will become an error in the next major version.
Warning: Protobuf detected an import path issue while loading generated file /usr/local/rvm/gems/ruby-3.1.4/gems/authzed-0.7.0/lib/authzed/api/v1/permission_service_pb.rb
Each proto file must use a consistent fully-qualified name.
This will become an error in the next major version.
Warning: Protobuf detected an import path issue while loading generated file /usr/local/rvm/gems/ruby-3.1.4/gems/authzed-0.7.0/lib/authzed/api/v1/experimental_service_pb.rb
Each proto file must use a consistent fully-qualified name.
This will become an error in the next major version.

Dependencies:

  • rails 7.1.1
  • google-protobuf (3.24.4-aarch64-linux)
  • google-protobuf (3.24.4-arm64-darwin)
  • google-protobuf (3.24.4-x86_64-linux)
  • grpc (1.59.2)
  • grpc-tools (1.59.2)

Please Add `LookupResources` Example

It's not clear how to interact with the stream-based responses. Can you please add an example that includes LookupResourcesRequest and LookupResourcesResponse and fetches a list of resources?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.