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

fix: fix the use of a hardcoded admin user #653

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

alesstimec
Copy link
Member

@alesstimec alesstimec commented Jan 7, 2025

Description

The terraform provider code used a hardcoded admin user in a number of place, which caused issues
if a different username (or client credentails) was used. With this change we use the username (or
clientID) as specified in the provider.

3.6 does not associate ssh keys with users - ssh keys are global per model - so the username
is ignored. For consistency we pass in the username that is used to log in to the
controller because in Juju 4 ssh keys will be associated with users.

Type of change

  • Logic changes in resources (the API interaction with Juju has been changed)

QA steps

Run JAAS integration tests.

@alesstimec alesstimec requested review from kian99 and hmlanigan January 8, 2025 12:29
@@ -104,6 +112,11 @@ func NewClient(ctx context.Context, config ControllerConfiguration) (*Client, er
defaultJAASCheck = true
}

user := config.Username
if config.ClientID != "" {
user = fmt.Sprintf("%s%s", config.ClientID, serviceAccountSuffix)
Copy link
Contributor

Choose a reason for hiding this comment

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

A small thing but in the future we might want to force the user to add the "@serviceaccount" suffix themselves. So you could consider only adding the suffix if it's not already present. Lots of "ifs" so feel free to ignore this.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@alesstimec alesstimec force-pushed the fix-hardcoded-admin-username branch from a258a7a to 7e2527d Compare January 8, 2025 13:18
Copy link
Contributor

@SimoneDutto SimoneDutto left a comment

Choose a reason for hiding this comment

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

lgtm

@alesstimec
Copy link
Member Author

/build

Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

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

This change works for now, however I wonder if juju 4 will break it: https://github.com/juju/juju/blob/f200bb872ee96b9b40c65b400171ad249e612627/apiserver/facades/client/keymanager/keymanager.go#L167-L177

Please add more description to the commit message around the above and sshkeys.

I did qa with a user with add-cloud permissions and had no problem on juju 3.5/edge.

internal/juju/sshKeys.go Outdated Show resolved Hide resolved
internal/juju/sshKeys.go Outdated Show resolved Hide resolved
internal/juju/sshKeys.go Outdated Show resolved Hide resolved
@alesstimec alesstimec force-pushed the fix-hardcoded-admin-username branch 2 times, most recently from 35d7274 to 575152c Compare January 15, 2025 11:33
The terraform provider code used a hardcoded `admin` user in a number of place, which caused issues
if a different username (or client credentails) was used. With this change we use the username (or
clientID) as specified in the provider.

This PR also changes the username that is passed in arguments to SSH key management calls. Juju
3.6 does not associate ssh keys with users - ssh keys are global per model - so the username
is ignored. For consistency we pass in the username that is used to log in to the
controller because in Juju 4 ssh keys will be associated with users.
@alesstimec alesstimec force-pushed the fix-hardcoded-admin-username branch from 575152c to 4a5e92b Compare January 15, 2025 11:35
@alesstimec alesstimec requested a review from hmlanigan January 15, 2025 11:35
@alesstimec
Copy link
Member Author

/merge

@jujubot jujubot merged commit 4fc8f89 into juju:main Jan 17, 2025
15 of 19 checks passed
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.

5 participants