-
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?
Conversation
ba4225b
to
e7a6bb2
Compare
@Martchus had the idea to put the env variables into the client so the deepest level. I think we can try to put the authentication token support into the client as well |
$host => {key => $key, secret => $secret} | ||
} split /,/, $ENV{OPENQA_WORKER_TOKEN} // $cli_options->{token} // ''; | ||
for (keys %tokens) { | ||
$webui_host_specific_settings{$_} ||= {}; |
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.
$webui_host_specific_settings{$_} ||= {}; |
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" :)
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 comment
The reason will be displayed to describe this comment to others. Learn more.
perl -wE'@a = split /|/, "abc|de"; say for @a'
a
b
c
|
d
e
You want split m/\|/
) 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Unquoted string "encode" may clash with future reserved word at -e line 1.
Argument "token" isn't numeric in subtraction (-) at -e line 1.
Argument "encode" isn't numeric in subtraction (-) at -e line 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.
sorry, I missed some local changes for that
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Why not reuse the decode_token
here?
Follow-up to
TODO: Cover in documentation