Skip to content
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

Access Token authentication #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

BeratUlualan
Copy link

Access Token authentication was added. -a or QTOKEN can be used for that.

Access Token authentication was added. -a or QTOKEN can be used for that.
Copy link
Collaborator

@Gandalf- Gandalf- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! This is long overdue, it's great to see.

Comment on lines +392 to +396
if ww.creds["QTOKEN"]:
ww.rc = RestClient(random.choice(ww.ips), ww.ww.creds.get("QPORT", REST_PORT), Credentials(ww.creds["QTOKEN"]))
else:
ww.rc.login(ww.creds["QUSER"], ww.creds["QPASS"])
# log_it("re-initialized Qumulo rest client for worker")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this a function or method so it doesn't need to be copy-pasted

Comment on lines +207 to +214
if self.creds["QTOKEN"]:
rc = RestClient(
self.creds["QHOST"], self.creds.get("QPORT", REST_PORT), Credentials(self.creds["QTOKEN"])
)
else:
rc = RestClient(self.creds["QHOST"], self.creds.get("QPORT", REST_PORT))
rc.login(self.creds["QUSER"], self.creds["QPASS"])

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this could be a function too; accept the creds object and produce a RestClient

Comment on lines 18 to +22
parser.add_argument(
"-p", help="Qumulo API password", default=os.getenv("QPASS") or "admin"
"-p", help="Qumulo API password", default=os.getenv("QPASS") or "'Admin123'"
)
parser.add_argument(
"-a", help="Qumulo access token", default=os.getenv("QTOKEN")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make these mutually exclusive (https://docs.python.org/3/library/argparse.html#mutual-exclusion) since you have the RestClient init prefer the token over the password. Which is reasonable, but I could see confusion if someone gives the script a valid password + invalid token, and it falls to connect

Better to make that situation impossible

Comment on lines +480 to +483
if ww.creds["QTOKEN"]:
ww.rc = RestClient(random.choice(ww.ips), ww.ww.creds.get("QPORT", REST_PORT), Credentials(ww.creds["QTOKEN"]))
else:
ww.rc.login(ww.creds["QUSER"], ww.creds["QPASS"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be solved when moving to a function, but let's make sure that none of the lines are longer than 100 characters

@Gandalf- Gandalf- added the enhancement New feature or request label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants