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

add logging to registerClient #1085

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECT_VERSION := 2.0.0-beta4
PROJECT_VERSION := 2.0.0-beta5
DOCKER_REPO := synfinatic
PROJECT_NAME := aws-sso
DOCKER_PROJECT_NAME := aws-sso-cli-ecs-server
Expand Down
7 changes: 5 additions & 2 deletions internal/sso/awssso_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,27 @@ const (
func (as *AWSSSO) registerClient(force bool) error {
log.Trace("registerClient()")
if !force {
log.Trace("Checking cache for RegisterClientData")
log.Trace("Checking cache for RegisterClientData", "storeKey", as.StoreKey())
err := as.store.GetRegisterClientData(as.StoreKey(), &as.ClientData)
if err == nil && !as.ClientData.Expired() {
log.Debug("Using RegisterClient cache", "storeKey", as.StoreKey())
return nil
}
}

log.Trace("Registering new client with AWS SSO")
input := ssooidc.RegisterClientInput{
ClientName: aws.String(as.ClientName),
ClientType: aws.String(as.ClientType),
// docs say this is optional, but it's required?
GrantTypes: []string{"refresh_token"},
Scopes: nil,
}
log.Trace("Registering new client with AWS SSO", "ClientName", as.ClientName, "ClientType", as.ClientType)
resp, err := as.ssooidc.RegisterClient(context.TODO(), &input)
if err != nil {
return fmt.Errorf("registerClient: %s", err.Error())
}
log.Trace("Registered new client with AWS SSO", "ClientId", aws.ToString(resp.ClientId), "ClientSecretExpiresAt", resp.ClientSecretExpiresAt)

as.ClientData = storage.RegisterClientData{
AuthorizationEndpoint: aws.ToString(resp.AuthorizationEndpoint), // not used?
Expand All @@ -187,10 +188,12 @@ func (as *AWSSSO) registerClient(force bool) error {
ClientSecretExpiresAt: resp.ClientSecretExpiresAt,
TokenEndpoint: aws.ToString(resp.TokenEndpoint), // not used?
}
log.Trace("SaveRegisterClientData start", "storeKey", as.StoreKey())
err = as.store.SaveRegisterClientData(as.StoreKey(), as.ClientData)
if err != nil {
log.Error("unable to save RegisterClientData", "storeKey", as.StoreKey(), "error", err.Error())
}
log.Trace("SaveRegisterClientData complete", "storeKey", as.StoreKey())
return nil
}

Expand Down
Loading