summaryrefslogtreecommitdiff
path: root/bin/rpc
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/rpc
parent534c909963f4d9ad4d4a8ec76d882cdf963f1811 (diff)
feat: remove standalone gRPC server
Diffstat (limited to 'bin/rpc')
-rwxr-xr-xbin/rpc51
1 files changed, 0 insertions, 51 deletions
diff --git a/bin/rpc b/bin/rpc
deleted file mode 100755
index 6d9c0f7..0000000
--- a/bin/rpc
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env ruby
-
-require "bundler/inline"
-
-gemfile do
- source "https://rubygems.org"
-
- gem "declarative_policy", "~> 1.0"
- gem "grpc", "~> 1.0"
- gem "grpc-tools", "~> 1.0"
- gem "logger", "~> 1.0"
-end
-
-lib_path = Pathname.new(__FILE__).parent.parent.join('lib/authx/rpc').realpath.to_s
-$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
-
-require 'ability_services_pb'
-
-class ProjectPolicy < DeclarativePolicy::Base
- condition(:owner) { @subject.owner?(@user) }
-
- rule { owner }.enable :create_project
-end
-
-class RawAbilityHandler < ::Authx::Rpc::Ability::Service
- def allowed(request, _call)
- puts [request, _call].inspect
- GRPC.logger.info([request, _call].inspect)
-
- ::Authx::Rpc::AllowReply.new(result: true)
- # TODO:: entrypoint to declarative policies
- # AllowReply.new(result: policy_for(request).can?(request.permission))
- end
-
- private
-
- def policy_for(request)
- # TODO:: convert subject in form of GlobalID to Resource Type
- DeclarativePolicy.policy_for(request.subject, request.resource)
- end
-end
-
-host = ENV.fetch("HOST", "localhost")
-port = ENV.fetch("PORT", "50051")
-bind_addr = "#{host}:#{port}"
-server = GRPC::RpcServer.new
-server.add_http2_port(bind_addr, :this_port_is_insecure)
-GRPC.logger = Logger.new($stderr, level: :debug)
-GRPC.logger.info("... running insecurely on #{bind_addr}")
-server.handle(RawAbilityHandler.new)
-server.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])