Skip to content

Commit

Permalink
Authorizer hits realish api
Browse files Browse the repository at this point in the history
* authorizer now hits the ruby api
* enable allowed end to end test
* add /authorized endpoint
  • Loading branch information
malakai97 committed Nov 13, 2023
1 parent 6d8b701 commit f453cc8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apache/module/mod_lauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static authz_status lauth_check_authorization(request_rec *r,
.user = r->user ? std::string(r->user) : ""
};

return Authorizer("http://mock-api:9000").isAllowed(req) ? AUTHZ_GRANTED : AUTHZ_DENIED;
return Authorizer("http://app.lauth.local:2300").isAllowed(req) ? AUTHZ_GRANTED : AUTHZ_DENIED;
}

static const authz_provider authz_lauth_provider =
Expand Down
15 changes: 15 additions & 0 deletions lauth/app/actions/authorize.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Lauth
module Actions
class Authorize < Lauth::Action

def handle(request, response)
response.format = :json
if request.params[:user] == "lauth-allowed"
response.body = { result: "allowed" }.to_json
else
response.body = { result: "denied" }.to_json
end
end
end
end
end
1 change: 1 addition & 0 deletions lauth/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
module Lauth
class Routes < Hanami::Routes
root { "Hello from Hanami" }
get "/authorized", to: "authorize"
end
end
2 changes: 1 addition & 1 deletion test/restrictions/umich_login_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
end
end

xcontext "when logged in as an authorized user" do
context "when logged in as an authorized user" do
it "is allowed" do
response = website.get("/user/") do |req|
req.headers["Authorization"] = basic_auth_good_user
Expand Down

0 comments on commit f453cc8

Please sign in to comment.