-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add initial local auth implementation #3
Conversation
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Prem Saraswat <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
cd74709
to
7948e09
Compare
Signed-off-by: Saswata Mukherjee <[email protected]>
@saswatamcode FYI there's a bug in the way that we are constructing URLs. I think we're missing a leading slash.
This was the login command I used
|
|
My other suggestion here would be to add an explicit log line, possibly at error level, indicating to the user when a command is not yet implemented.
|
Struggling to login with certain URLs 🤔
Which is weird because if I then try and run
But then when I re-run the original command it passes successfully 🤷 |
@saswatamcode I think this is a fantastic start and already I can see how this is going to make our lives much easier when interacting with observatorium 🎉 however, there are a couple of rough edges that are reducing my enjoyment of this CLI that we should get ironed out :) |
@ianbillett thanks for testing this out! I'll try and tackle those rough edges!
Labelvalues requires a name flag as per API, will mark that flag as required.
For the login Edit: Fixed and added a context list command as well. |
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
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.
Great work @saswatamcode 👏 I have added some comments, I'd be happy to give it a test spin soon as well!
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
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.
Just tested obsctl
= 🤩
I left few suggestions, perhaps they do not need addressing now but in future PRs.
I'd only request changing the auth.go
filename, otherwise good to go 🚢
return err | ||
} | ||
|
||
for k, v := range conf.APIs { |
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.
If we have API's specified, but no tenants, is that a valid context? It was a bit confusing since only APIs were listed when I had no tenants added - but that means those contexts are not valid / usable, right?
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.
Context means an API name and a tenant name using which we can do an operation (will add docs soon to clarify this well 🙂). An API can exist in the config without a tenant (although you can't make requests like that), but a tenant cannot exist without an API.
So in this case, it means they aren't usable. You need to add a tenant under your already added API.
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 think I understand that, but then we're listing 'unusable' contexts, which is not useful for the user.
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.
Hmm, that's correct. Let's add an issue once this is merged and figure out a nice way to display contexts in an easily understandable way in future PRs. Maybe adding a " no tenant, cannot use yet" text beside the API name which has no tenants would be reasonable? 🙂
} | ||
|
||
listCmd := &cobra.Command{ | ||
Use: "list", |
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 was also wondering whether it would make sense to add list
command for APIs as well?
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.
The list command lists out all possible context in the form of,
API1:
- tenant1
- tenant2
API2:
- tenant1
- tenant2
So might not need a separate list command for only API.
But one thing that I would want to add is a verbose mode by which we can print out all details or all tenant and APIs.
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 think it still might be useful, especially if you have no context defined so far or if you want a higher-level view of which APIs you currently have in your config. If we can add and remove an entity, then it makes to me to list as well. But yes, it's achievable through context
command to a degree, so it's not a blocker.
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.
Let's iterate on a future PR! 🙂
Signed-off-by: Saswata Mukherjee <[email protected]>
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.
LGTM!
This PR adds the initial local authentication implementation for obsctl,
context api add
andcontext api rm
functionality, which saves an Observatorium API instance with a given name or hostname, locally in .config/obs/config.json`login
functionality, which saves configuration for a tenant, including OIDC config and token, also in.config/obs/config.json
logout
command which removes locally saved tenant configcontext switch <api name>/<tenant name>
andcontext current
functionality for viewing and changing contextcontext list
to display all locally saved contextsobsctl metrics set --rule.file=
)TODOs (which will be handled in subsequent PRs),