Implemented basic client config for auth
This commit is contained in:
@@ -44,10 +44,10 @@ module Faaso
|
||||
outf << buf
|
||||
end
|
||||
|
||||
url = "#{FAASO_SERVER}funkos/build/"
|
||||
url = "#{Faaso.server}funkos/build/"
|
||||
|
||||
begin
|
||||
Log.info { "Uploading funko to #{FAASO_SERVER}" }
|
||||
Log.info { "Uploading funko to #{Faaso.server}" }
|
||||
Log.info { "Starting remote build:" }
|
||||
Crest.post(
|
||||
url,
|
||||
|
29
src/commands/login.cr
Normal file
29
src/commands/login.cr
Normal file
@@ -0,0 +1,29 @@
|
||||
module Faaso
|
||||
module Commands
|
||||
struct Login
|
||||
def run(options) : Int32
|
||||
server = Faaso.server
|
||||
Log.info { "Enter password for #{server}" }
|
||||
if STDIN.tty?
|
||||
password = (STDIN.noecho &.gets.try &.chomp).to_s
|
||||
else
|
||||
password = STDIN.gets.to_s
|
||||
end
|
||||
# Testing with auth/ which is guaranteed locked
|
||||
Crest.get(
|
||||
"#{server}auth/", \
|
||||
user: "admin", password: password).body
|
||||
# If we got here the password is ok
|
||||
CONFIG.hosts[server] = {"admin", password}
|
||||
Config.save
|
||||
0
|
||||
rescue ex : Crest::Unauthorized
|
||||
Log.error { "Wrong password" }
|
||||
1
|
||||
rescue ex : Socket::ConnectError
|
||||
Log.error { "Connection refused" }
|
||||
1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -30,7 +30,7 @@ module Faaso
|
||||
Faaso.check_version
|
||||
if !scale
|
||||
Crest.get(
|
||||
"#{FAASO_SERVER}funkos/#{name}/scale/", \
|
||||
"#{Faaso.server}funkos/#{name}/scale/", \
|
||||
user: "admin", password: "admin") do |response|
|
||||
loop do
|
||||
Log.info { response.body_io.gets }
|
||||
@@ -39,7 +39,7 @@ module Faaso
|
||||
end
|
||||
else
|
||||
Crest.post(
|
||||
"#{FAASO_SERVER}funkos/#{name}/scale/",
|
||||
"#{Faaso.server}funkos/#{name}/scale/",
|
||||
{"scale" => scale}, user: "admin", password: "admin") do |response|
|
||||
loop do
|
||||
Log.info { response.body_io.gets }
|
||||
|
@@ -16,7 +16,7 @@ module Faaso
|
||||
Faaso.check_version
|
||||
if options["--add"]
|
||||
Crest.post(
|
||||
"#{FAASO_SERVER}secrets/",
|
||||
"#{Faaso.server}secrets/",
|
||||
{
|
||||
"funko" => funko,
|
||||
"name" => name,
|
||||
@@ -25,7 +25,7 @@ module Faaso
|
||||
Log.info { "Secret created" }
|
||||
elsif options["--delete"]
|
||||
Crest.delete(
|
||||
"#{FAASO_SERVER}secrets/#{funko}/#{name}",
|
||||
"#{Faaso.server}secrets/#{funko}/#{name}",
|
||||
user: "admin", password: "admin")
|
||||
end
|
||||
0
|
||||
|
@@ -28,7 +28,7 @@ module Faaso
|
||||
def remote(options, name) : Int32
|
||||
Faaso.check_version
|
||||
Crest.get(
|
||||
"#{FAASO_SERVER}funkos/#{name}/status/", \
|
||||
"#{Faaso.server}funkos/#{name}/status/", \
|
||||
user: "admin", password: "admin") do |response|
|
||||
loop do
|
||||
Log.info { response.body_io.gets }
|
||||
|
Reference in New Issue
Block a user