summaryrefslogtreecommitdiff
path: root/bin/api
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-03-06 12:27:03 -0700
committermo khan <mo@mokhan.ca>2025-03-06 12:27:03 -0700
commit68aaecae08062f6a200bc7167e8666c14165630c (patch)
tree830f1ddb5ce40504b33976ec598a91b70d10d083 /bin/api
parent534c909963f4d9ad4d4a8ec76d882cdf963f1811 (diff)
feat: remove standalone gRPC server
Diffstat (limited to 'bin/api')
-rwxr-xr-xbin/api23
1 files changed, 6 insertions, 17 deletions
diff --git a/bin/api b/bin/api
index 0330dc82..d3c53175 100755
--- a/bin/api
+++ b/bin/api
@@ -5,8 +5,9 @@ require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
+ gem "declarative_policy", "~> 1.0"
gem "erb", "~> 4.0"
- gem "grpc", "~> 1.0"
+ gem "google-protobuf", "~> 3.0"
gem "json", "~> 2.0"
gem "logger", "~> 1.0"
gem "rack", "~> 3.0"
@@ -21,7 +22,6 @@ $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
require 'authx'
-GRPC.logger = Logger.new($stderr, level: :debug)
$scheme = ENV.fetch("SCHEME", "http")
$port = ENV.fetch("PORT", 8284).to_i
$host = ENV.fetch("HOST", "localhost:#{$port}")
@@ -80,21 +80,10 @@ 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)
- 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
+ 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
end
def json_not_found