From d732d93176abee0351c6465c77043658408e4cae Mon Sep 17 00:00:00 2001 From: Finn Ickler Date: Sun, 22 Oct 2023 16:05:27 +0200 Subject: [PATCH] fix talking with permissions on the monolith --- app/helpers/user_api.rb | 10 ++++------ app/helpers/wca_api.rb | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/helpers/user_api.rb b/app/helpers/user_api.rb index ccdc9f57..54cad82e 100644 --- a/app/helpers/user_api.rb +++ b/app/helpers/user_api.rb @@ -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? @@ -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 diff --git a/app/helpers/wca_api.rb b/app/helpers/wca_api.rb index 90346edf..4ef59493 100644 --- a/app/helpers/wca_api.rb +++ b/app/helpers/wca_api.rb @@ -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