aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/terraform_http_backend_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/terraform_http_backend_controller.rb')
-rw-r--r--app/controllers/terraform_http_backend_controller.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/app/controllers/terraform_http_backend_controller.rb b/app/controllers/terraform_http_backend_controller.rb
index 4587f8a..eeff7b0 100644
--- a/app/controllers/terraform_http_backend_controller.rb
+++ b/app/controllers/terraform_http_backend_controller.rb
@@ -19,7 +19,27 @@
# <http://www.gnu.org/licenses/>.
class TerraformHttpBackendController < ApplicationController
- skip_before_action :verify_authenticity_token
+ skip_before_action :verify_authenticity_token, only: %w(create show destroy)
+
+ def self.credentials
+ @_credentials ||= begin
+ # Hopefully there is a simpler way of doing this, but it'll do
+ # for now.
+ verifier = ActiveSupport::MessageVerifier.new(
+ Rails.application.secrets[:secret_key_base]
+ )
+
+ {
+ name: 'terraform',
+ password: verifier.generate('tpw')
+ }
+ end
+ end
+
+ http_basic_authenticate_with(
+ **credentials,
+ only: %(create show destroy)
+ )
def index
@all_states = TerraformState.all.group_by(&:state_id)