Skip to content

Commit

Permalink
Merge pull request #1085 from synfinatic/register-new-client
Browse files Browse the repository at this point in the history
add logging to registerClient
  • Loading branch information
synfinatic authored Oct 22, 2024
2 parents 6660bfc + 4c2ab79 commit c441072
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit c441072

Please sign in to comment.