Skip to content

Conversation

@marpauli-cisco
Copy link
Collaborator

  • added ability to authorize ClientLibrary with JWT
  • if credentials are not provided, PCL will prompt to choose auth type (JWT or usr/pwd)
  • authok url changed to authentication
  • url for authentication changed from auth_test to auth, because we are using also for getting username when authorized with JWT

@marpauli-cisco
Copy link
Collaborator Author

IMHO there is one downside to using ClientConfig for storing configuration - it is NamedTuple, so once created, we are unable to update it without completely rewriting it. Right now, it is not a problem, because we are not altering in anywhere in code, but we have to have it in mind in the future...
also, there are some (11) failing test, that I've missed, so I'm going to fix them and push, in case someone was itching to approve this 🤣

@tmikuska tmikuska changed the title Cmldev 727 jwt authentication in client library CMLDEV-727 JWT authentication Jan 9, 2026
raise InitializationError(exc)
user_info = response.json()
self.user_id = user_info.get("id")
self.admin = user_info.get("admin", False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need user_id and admin?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would fetch user_id at least for all auth methods (i.e. when doing user/pass); I recall some model actually wanted to know it at some point, and maybe fetches it on the fly. Knowing whether we are an admin can become useful too.

self.user_id = user_info.get("id")
self.admin = user_info.get("admin", False)
if self.username is None:
self.username = user_info.get("username")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd overwrite username all the time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants