diff options
Diffstat (limited to 'bin/api')
| -rwxr-xr-x | bin/api | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -12,6 +12,7 @@ gemfile do gem "rack", "~> 3.0" gem "rackup", "~> 2.0" gem "securerandom", "~> 0.1" + gem "twirp", "~> 1.0" gem "webrick", "~> 1.0" end @@ -79,12 +80,21 @@ class API def authorized?(request, permission) # TODO:: Check the JWT for the appropriate claim # Connect to the Authz RPC endpoint Ability.allowed?(subject, permission, resource) - client = ::Authx::Rpc::Ability::Stub.new('localhost:50051', :this_channel_is_insecure) # TODO:: memorize client - reply = client.allowed(::Authx::Rpc::AllowRequest.new(subject: "", permission: permission, resource: "")) - puts "***" * 10 - puts reply.inspect - puts "***" * 10 - reply&.result + if twirp? + client = ::Authx::Rpc::AbilityClient.new("http://idp.example.com:8080/twirp") + response = client.allowed(subject: "", permission: permission, resource: "") + puts response.inspect + response&.error&.nil? && response&.data&.result + else + client = ::Authx::Rpc::Ability::Stub.new('localhost:50051', :this_channel_is_insecure) # TODO:: memorize client + reply = client.allowed(::Authx::Rpc::AllowRequest.new(subject: "", permission: permission, resource: "")) + puts reply.inspect + reply&.result + end + end + + def twirp? + true end def json_not_found |
