summaryrefslogtreecommitdiff
path: root/bin/rpc
diff options
context:
space:
mode:
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 6d9c0f79..00000000
--- 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'])