Skip to content

Command to switch active user #417

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

Open
Darkhood148 opened this issue Apr 15, 2025 · 12 comments
Open

Command to switch active user #417

Darkhood148 opened this issue Apr 15, 2025 · 12 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed Priority: Medium Affecting a limited number of users,degrading the customer experience.

Comments

@Darkhood148
Copy link
Contributor

Darkhood148 commented Apr 15, 2025

Issue:

harbor login is used to add new credentials to config.yaml and switch to the newly added credentials. However there is no command to switch between already added credentials.

Solution:

Add a new command:

harbor config switch <username>

This command will switch to the credentials with the username that is provided; given it is available in the config.yaml

@Darkhood148
Copy link
Contributor Author

/assign

@meethereum
Copy link
Contributor

hey! just trying to figure out if I understand it. Does this :

harbor login <server address> -u <username> -p <password>

already not suffice the requirement?

@Darkhood148
Copy link
Contributor Author

When you have already saved your credentials once, there is no need to enter password again and again. Similar to how you can have multiple accounts on a website and switch accounts without having to enter your password again and again

@meethereum
Copy link
Contributor

When you have already saved your credentials once, there is no need to enter password again and again. Similar to how you can have multiple accounts on a website and switch accounts without having to enter your password again and again

Gotcha. I believe we have to be really careful about security when implementing this. Since harbor allows RBAC, logging in without passwords could be tricky. Let me know what you guys think.

@bupd
Copy link
Collaborator

bupd commented Apr 16, 2025

I would suggest using harbor config switch. @Darkhood148

@Darkhood148
Copy link
Contributor Author

Gotcha. I believe we have to be really careful about security when implementing this. Since harbor allows RBAC, logging in without passwords could be tricky. Let me know what you guys think.

I was thinking of a simpler approach. Search for the username in the config, if it doesn't exist, throw an error. If it exists, prompt the user to select the serveraddress that he wants. Then we can set current-credential-name according to that

@Vad1mo
Copy link
Member

Vad1mo commented Apr 16, 2025

IMO Harbor config switch isn't clear. It misses the what...

My suggestion would be context

Let then user select based on context name.

@qcserestipy
Copy link
Collaborator

qcserestipy commented Apr 16, 2025

We had this discussion already in this issue: #275
There it was the idea of using a context command. In that issue it was decided that context switching could be currently handled with the login --name flag. I think the argument was that a seperate command could lead to confusion. As an addition the user can currently change the context by using the config set command for the current-credential-name setting. Including a context command would mean that the user has now three different ways to do the context switching.

IMHO, introducing a context command could come in handy while limiting the other ways of context switching to remove possibility for confusion or "messing around".

@Vad1mo
Copy link
Member

Vad1mo commented Apr 16, 2025

There it was the idea of using a context command. In that issue it was decided that context switching could be currently handled with the login --name flag. I think the argument was that a seperate command could lead to confusion. As an addition the user can currently change the context by using the config set command for the current-credential-name setting. Including a context command would mean that the user has now three different ways to do the context switching.

IMHO, introducing a context command could come in handy while limiting the other ways of context switching to remove possibility for confusion or "messing around".

thank you for pointing that out.
I do agree, we should not have multiple ways to accomplish that same thing.

While login --name allows switching the context, I don't think it's not a common thing, also that fact that nobody found it out by themselves emphasizes that's.

Before moving forward, we should agree on the one single option!

@bupd
Copy link
Collaborator

bupd commented Apr 17, 2025

Yes, I think it should like this.

we can use harbor-cli context for managing the context.

harbor-cli context list  // to list available contexts to use
harbor-cli context use  [context-name]  // to use the specified context

Because harbor config in future can grow into more different options.

@bupd
Copy link
Collaborator

bupd commented Apr 17, 2025

We should also document this harbor-cli login --name [credential-name]. to use credentials that we have already used.

@bupd bupd added enhancement New feature or request help wanted Extra attention is needed Priority: Medium Affecting a limited number of users,degrading the customer experience. labels Apr 17, 2025
@Darkhood148
Copy link
Contributor Author

Sounds great. I can start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed Priority: Medium Affecting a limited number of users,degrading the customer experience.
Projects
None yet
Development

No branches or pull requests

5 participants