-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Add cookie support for Pull mode jobs executed from NuvlaEdge #399
base: main
Are you sure you want to change the base?
Conversation
def _init_nuvla_api(self): | ||
# true unless header authentication is used | ||
reauthenticate = self.args.api_authn_header is None | ||
cookies = os.getenv("JOB_COOKIES", "") | ||
persist_cookie = cookies != "" and cookies is not None |
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.
could be simplified with
persist_cookie = cookies != "" and cookies is not None | |
persist_cookie = bool(cookies) |
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.
I would use a tmpfile for the cookie file.
But in fact, why writing the cookie to a file ?
After the Api instance is created it's possible to do:
self.api = Api(...)
self.api.session.cookies.set_cookie(cookie)
In this case it needs to be a (single) cookie like returned by the Set-Cookie HTTP header.
But you can load a mozilla cookie file in memory with BytesIO
(or StringIO
):
self.api = Api(...)
self.api.session.cookies = MozillaCookieJar()
self.api.session.cookies._really_load(BytesIO(cookies), '', ignore_discard=True)
Please also see the review comment in the other PR: nuvlaedge/nuvlaedge#214 (review) |
Closes sixsq/tasklist#3225