Class: MissionControl::Jobs::Authentication

Inherits:
Rails::Command::Base
  • Object
show all
Defined in:
lib/mission_control/jobs/authentication.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configureObject



4
5
6
# File 'lib/mission_control/jobs/authentication.rb', line 4

def self.configure
  new.configure
end

Instance Method Details

#configureObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mission_control/jobs/authentication.rb', line 8

def configure
  if credentials_accessible?
    if authentication_configured?
      say "HTTP Basic Authentication is already configured for `#{Rails.env}`. You can edit it using `credentials:edit`"
    else
      say "Setting up credentials for HTTP Basic Authentication for `#{Rails.env}` environment."
      say ""

      username = ask "Enter username: "
      password = SecureRandom.base58(64)

      store_credentials(username, password)
      say "Username and password stored in Rails encrypted credentials."
      say ""
      say "You can now access Mission Control – Jobs with: "
      say ""
      say " - Username: #{username}"
      say " - password: #{password}"
      say ""
      say "You can also edit these in the future via `credentials:edit`"
    end
  else
    say "Rails credentials haven't been configured or aren't accessible. Configure them following the instructions in `credentials:help`"
  end
end