summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/api6
-rwxr-xr-xbin/idp5
-rwxr-xr-xbin/rpc6
3 files changed, 11 insertions, 6 deletions
diff --git a/bin/api b/bin/api
index 15e63b7..1a47d14 100755
--- a/bin/api
+++ b/bin/api
@@ -18,7 +18,7 @@ end
lib_path = Pathname.new(__FILE__).parent.parent.join('lib').realpath.to_s
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
-require 'ability_services_pb'
+require 'authx'
GRPC.logger = Logger.new($stderr, level: :debug)
$scheme = ENV.fetch("SCHEME", "http")
@@ -79,8 +79,8 @@ 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::Ability::Stub.new('localhost:50051', :this_channel_is_insecure) # TODO:: memorize client
- reply = client.allowed(::Authx::AllowRequest.new(subject: "", permission: 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
diff --git a/bin/idp b/bin/idp
index bc949d2..f43d495 100755
--- a/bin/idp
+++ b/bin/idp
@@ -13,6 +13,11 @@ gemfile do
gem "webrick", "~> 1.0"
end
+lib_path = Pathname.new(__FILE__).parent.parent.join('lib').realpath.to_s
+$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
+
+require 'authx'
+
$scheme = ENV.fetch("SCHEME", "http")
$port = ENV.fetch("PORT", 8282).to_i
$host = ENV.fetch("HOST", "localhost:#{$port}")
diff --git a/bin/rpc b/bin/rpc
index 92c8c82..d0c1cd8 100755
--- a/bin/rpc
+++ b/bin/rpc
@@ -11,7 +11,7 @@ gemfile do
gem "logger", "~> 1.0"
end
-lib_path = Pathname.new(__FILE__).parent.parent.join('lib').realpath.to_s
+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'
@@ -22,12 +22,12 @@ class ProjectPolicy < DeclarativePolicy::Base
rule { owner }.enable :create_project
end
-class AbilityHandler < ::Authx::Ability::Service
+class AbilityHandler < ::Authx::Rpc::Ability::Service
def allowed(request, _call)
puts [request, _call].inspect
GRPC.logger.info([request, _call].inspect)
- ::Authx::AllowReply.new(result: true)
+ ::Authx::Rpc::AllowReply.new(result: true)
# TODO:: entrypoint to declarative policies
# AllowReply.new(result: policy_for(request).can?(request.permission))
end