Class: Railspress::Admin::AgentBootstrapKeysController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Railspress::Admin::AgentBootstrapKeysController
- Defined in:
- app/controllers/railspress/admin/agent_bootstrap_keys_controller.rb
Constant Summary collapse
- DEFAULT_BOOTSTRAP_TTL =
1.hour
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/railspress/admin/agent_bootstrap_keys_controller.rb', line 16 def create @agent_bootstrap_key, @plain_bootstrap_token = AgentBootstrapKey.issue!( name: agent_bootstrap_key_params[:name], actor: current_api_actor, owner: current_api_actor, expires_at: parsed_expires_at || default_bootstrap_expires_at ) set_bootstrap_instructions render :reveal, status: :created rescue ActiveRecord::RecordInvalid => e @agent_bootstrap_key = e.record render :new, status: :unprocessable_content end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/railspress/admin/agent_bootstrap_keys_controller.rb', line 12 def new @agent_bootstrap_key = AgentBootstrapKey.new(expires_at: default_bootstrap_expires_at) end |
#revoke ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/railspress/admin/agent_bootstrap_keys_controller.rb', line 31 def revoke @agent_bootstrap_key.revoke!( actor: current_api_actor, reason: params[:reason].presence || "revoked" ) redirect_to admin_api_keys_path, notice: "Agent bootstrap key revoked." end |