Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #329 from rishabhs95/worker-auth
Browse files Browse the repository at this point in the history
probable repair for auth
  • Loading branch information
pwnbus committed Feb 9, 2017
2 parents 108b4bc + e249ef5 commit 20ab2c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions config/api/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
port: 8000

# API Tokens (a crude mechanism for adding auth to your API)
#authentication: true
authentication: false
authentication: true
# authentication: false

# If authentication is to true, the authentication tokens you generate below
# will be required to access certain API functions.
Expand All @@ -23,6 +23,10 @@ authentication: false
# - username : gamora
# token : INSERT_GAMORA_TOKEN

workers:
- worker_name : worker1
token : token1

# Define database configuration
# MongoDB Example
# database:
Expand Down
6 changes: 6 additions & 0 deletions lib/ssh_scan/authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def valid_token?(token)
end
end

if @config["workers"]
@config["workers"].each do |worker|
return true if worker["token"] == token
end
end

return false
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/ssh_scan/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def retrieve_work
end

request = Net::HTTP::Get.new(uri.path)
request.add_field("SSH_SCAN_AUTH_TOKEN", ENV.fetch('HTTP_SSH_SCAN_AUTH_TOKEN'))
response = http.request(request)
JSON.parse(response.body)
end
Expand Down Expand Up @@ -108,6 +109,7 @@ def post_results(results, job)
end

request = Net::HTTP::Post.new(uri.path)
request.add_field("SSH_SCAN_AUTH_TOKEN", ENV.fetch('HTTP_SSH_SCAN_AUTH_TOKEN'))
request.body = results.to_json
http.request(request)
@logger.info("Posted job: #{job["uuid"]}")
Expand Down

0 comments on commit 20ab2c1

Please sign in to comment.