-
Notifications
You must be signed in to change notification settings - Fork 219
Add support for worker authentication tokens #6768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,12 +25,19 @@ | |
# the websocket connection to receive commands from the web UI and send the status (Mojo::Transaction::WebSockets instance) | ||
has 'websocket_connection'; | ||
|
||
sub new ($class, $webui_host, $cli_options) { | ||
|
||
|
||
sub new ($class, $webui_host, $args) { | ||
$webui_host = $ENV{OPENQA_WORKER_WEBUI_HOST} // $webui_host; | ||
my $url = $webui_host !~ '/' ? Mojo::URL->new->scheme('http')->host_port($webui_host) : Mojo::URL->new($webui_host); | ||
my ($host, $key, $secret) = split /|/, $ENV{OPENQA_WORKER_TOKEN} if $ENV{OPENQA_WORKER_TOKEN}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not reuse the |
||
$host //= $ENV{OPENQA_WORKER_HOST}; | ||
$key //= $ENV{OPENQA_WORKER_APIKEY}; | ||
$secret //= $ENV{OPENQA_WORKER_APISECRET}; | ||
my $ua = OpenQA::Client->new( | ||
api => $url->host, | ||
apikey => $cli_options->{apikey}, | ||
apisecret => $cli_options->{apisecret}, | ||
apikey => $ENV{OPENQA_WORKER_APIKEY} // $args->{apikey}, | ||
apisecret => $ENV{OPENQA_WORKER_APISECRET} // $args->{apisecret}, | ||
); | ||
$ua->base_url($url); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,16 @@ specify the public key needed for API authentication | |
|
||
specify the secret key needed for API authentication | ||
|
||
=item B<--token> <value> | ||
|
||
specify a comma-separated list of tokens for C<host>@C<key>@C<secret> | ||
combinations as alternative to the individual options. Alternatively use the | ||
environment variable C<OPENQA_WORKER_TOKEN>. | ||
|
||
=item B<--encode-token> HOST@KEY@SECRET | ||
d3flex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Encode a token as string for the specified host+key+secret combination | ||
|
||
=item B<--isotovideo> PATH | ||
|
||
path to isotovideo script, useful for running from git | ||
|
@@ -97,11 +107,13 @@ my %options; | |
sub usage ($r) { require Pod::Usage; Pod::Usage::pod2usage($r) } | ||
|
||
GetOptions( | ||
\%options, "no-cleanup", "instance=i", "isotovideo=s", "host=s", "apikey:s", | ||
"apisecret:s", "verbose|v|debug|d", "help|h", | ||
\%options, "no-cleanup", "instance=i", "isotovideo=s", | ||
"host=s", "apikey:s", "apisecret:s", "token:s", | ||
"encode-token:s", "verbose|v|debug|d", "help|h", | ||
) or usage(1); | ||
|
||
usage(0) if ($options{help}); | ||
exit !OpenQA::Worker::encode_token($options{encode-token}) if $options{encode-token}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, I missed some local changes for that |
||
|
||
# count workers from 1 if not set - if tap devices are used worker would try to use tap -1 | ||
$options{instance} ||= 1; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you think this line isn't necessary? Isn't that needed for auto-vivification so that we can write values into the inner hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-vivifaction is exactly why it isn't needed, that's why it's called "auto" :)