Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
fix talking with permissions on the monolith
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnIckler committed Oct 22, 2023
1 parent d1cfac8 commit d732d93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions app/helpers/user_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
require_relative 'mocks'
require_relative 'wca_api'

def permissions_path(user_id)
"https://#{EnvConfig.WCA_HOST}/api/internal/v1/users/#{user_id}/permissions"
end

class UserApi < WcaApi
def self.get_permissions(user_id)
if Rails.env.production?
Expand All @@ -29,10 +33,4 @@ def self.can_administer?(user_id, competition_id)
end
permissions['can_administer_competitions']['scope'] == '*' || permissions['can_administer_competitions']['scope'].include?(competition_id)
end

class << self
def permissions_path(user_id)
"#{WCA_HOST}/api/internal/v1/users/#{user_id}/permissions"
end
end
end
4 changes: 2 additions & 2 deletions app/helpers/wca_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class WcaApi
# Uses Vault ID Tokens: see https://developer.hashicorp.com/vault/docs/secrets/identity/identity-token
def self.get_wca_token
Vault.with_retries(Vault::HTTPConnectionError) do
data = Vault.logical.read("identity/oidc/token/#{@vault_application}")
data = Vault.logical.read("identity/oidc/token/#{EnvConfig.VAULT_APPLICATION}")
if data.present?
data.data[:data][:token]
data.data[:token]
else # TODO: should we hard error out here?
puts 'Tried to get identity token, but got error'
end
Expand Down

0 comments on commit d732d93

Please sign in to comment.