-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: implement Service Account / Local Users #3215
Conversation
5b1e3db
to
148e925
Compare
Codecov Report
@@ Coverage Diff @@
## master #3215 +/- ##
==========================================
+ Coverage 38.81% 38.99% +0.17%
==========================================
Files 169 172 +3
Lines 18321 18764 +443
Branches 272 237 -35
==========================================
+ Hits 7112 7317 +205
- Misses 10333 10540 +207
- Partials 876 907 +31
Continue to review full report at Codecov.
|
13878e6
to
cc73f4f
Compare
cc73f4f
to
feb513b
Compare
cccec64
to
1f400db
Compare
1f400db
to
58e0259
Compare
3cbd93f
to
ee02a6e
Compare
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.
Wow, awesome work. Looks good to me so far, I have some minor comments see below.
cmd/argocd/commands/account.go
Outdated
Use: "get", | ||
Short: "Get account details", | ||
Example: "argocd account get", |
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.
IMHO should provide information on the argument the command optional takes - i.e. the account name. Also should be made clear in the example that with no parameters, current account will be get, and if parameter given, information for named account will be retrieved.
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.
Agree. Updated example of all commands that defaults to the current account.
cmd/argocd/commands/account.go
Outdated
Use: "generate-token", | ||
Short: "Generate account token", | ||
Example: "argocd account generate-token", |
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.
Same as above, information about the arguments should be given.
cmd/argocd/commands/account.go
Outdated
Use: "delete-token", | ||
Short: "Deletes account token", | ||
Example: "argocd account delete-token ID", |
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.
Here as well - more information about the parameters, please.
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.
done
@@ -38,8 +38,6 @@ const ( | |||
|
|||
// Default paths on the pod's file system | |||
const ( | |||
// The default base path where application config is located | |||
DefaultPathAppConfig = "/app/config" |
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.
Hm, is this not used anywhere?
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.
Yes, look like we forgot to delete it after some refactoring.
server/account/account.go
Outdated
@@ -28,39 +30,49 @@ type Server struct { | |||
// NewServer returns a new instance of the Session service | |||
func NewServer(sessionMgr *session.SessionManager, settingsMgr *settings.SettingsManager, enf *rbac.Enforcer) *Server { | |||
return &Server{sessionMgr, settingsMgr, enf} | |||
|
|||
} | |||
|
|||
// UpdatePassword updates the password of the local admin superuser. |
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.
This comment should be adapted to reflect reality. Probably there are 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.
fixed
server/account/account.proto
Outdated
rpc GetAccount(GetAccountRequest) returns (Account) { | ||
option (google.api.http).get = "/api/v1/account/{name}"; | ||
} |
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.
Indentation
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.
fixed
return &s | ||
} | ||
|
||
// Create creates a new token for a given subject (user) and returns it as a string. | ||
// Passing a value of `0` for secondsBeforeExpiry creates a token that never expires. | ||
func (mgr *SessionManager) Create(subject string, secondsBeforeExpiry int64) (string, error) { | ||
func (mgr *SessionManager) Create(subject string, secondsBeforeExpiry int64, id string) (string, error) { |
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.
We should clarify what id
is used for here.
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.
done. Updated comment
@@ -0,0 +1,307 @@ | |||
package settings |
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.
General thought on this package - I think all Public methods and types should be rather well commented.
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.
Agree. Added missing comments
util/settings/accounts.go
Outdated
} | ||
|
||
func parseAdminAccount(secret *v1.Secret, cm *v1.ConfigMap) (*Account, error) { | ||
adminAccount := &Account{Enabled: true, Capabilities: []AccountCapability{AccountCapabilityApiKey, AccountCapabilityLogin}} |
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.
Hm, do we really want to allow admin account access to API by default? Or is that for backwards compatibility? If so, we should make a deprecation notice, that admin access to API will be disabled from v2 onwards or something similar.
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.
Nice catch. Admin account should not be able to generate API keys by default. That functionality does not exist before 1.5 so we are not breaking backward compatibility. Updated the default capabilities.
@@ -0,0 +1,67 @@ | |||
package settings |
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.
General thought on this test package. I think we should also test for bad/malformed input data, that would also come up with more code coverage.
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.
Done. Added missing tests
ee02a6e
to
214a6fa
Compare
Thank you for review @jannfis ! PTAL |
214a6fa
to
0da95f0
Compare
0da95f0
to
536e323
Compare
536e323
to
0addefc
Compare
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
@alexmt: thanks for the documentation part |
Something unclear to me - look like you can define a token in the config map (by looking on the PR), but how can you use this token? What defined in the PR is claims, how can I sign it? |
hello @omerlh , User copy generated token and use it same as token generated during normal login process. Only token id, issuedAt and expiringAt time fields are stored in secret. This allows user to know when the token is going to expire and revoke it if necessary |
So there is no declarative way to create tokens? only using the CLI? |
for i := range a.Capabilities { | ||
items = append(items, string(a.Capabilities[i])) | ||
} | ||
return strings.Join(items, ",") |
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.
This results in "apiKey, login"
getting turned into "apiKey,login"
Closes #3185
Closes #2108
Closes #3221
PR introduces local users support in Argo CD.
CLI commands
UI