Skip to content

Commit 4f914ad

Browse files
committed
get currently authenticated user for validate
1 parent 14cfb66 commit 4f914ad

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

pkg/connector/connector.go

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,35 @@ func (d *Connector) Metadata(ctx context.Context) (*v2.ConnectorMetadata, error)
8888
func (d *Connector) Validate(ctx context.Context) (annotations.Annotations, error) {
8989
var outputAnnotations = annotations.New()
9090
if !d.client.IsOnPremise {
91-
// Logic for GitLab Cloud.
92-
if d.client.AccountCreationGroup != "" {
93-
// If an account creation group is set, validate it exists and is unique.
94-
groupName := d.client.AccountCreationGroup
95-
_, rateLimitDesc, err := d.client.FindGroupByName(ctx, groupName)
96-
if rateLimitDesc != nil {
97-
outputAnnotations.WithRateLimiting(rateLimitDesc)
98-
}
99-
if err != nil {
100-
return outputAnnotations, fmt.Errorf("failed to validate account creation group: %w", err)
101-
}
102-
} else {
103-
// If no account creation group is set, perform a general token validation.
104-
_, rateLimitDesc, err := d.client.GetCurrentlyAuthenticatedUser(ctx)
105-
if rateLimitDesc != nil {
106-
outputAnnotations.WithRateLimiting(rateLimitDesc)
107-
}
108-
if err != nil {
109-
return outputAnnotations, fmt.Errorf("error validating token with GetCurrentlyAuthenticatedUser: %w", err)
110-
}
91+
// If no account creation group is set, perform a general token validation.
92+
_, rateLimitDesc, err := d.client.GetCurrentlyAuthenticatedUser(ctx)
93+
if rateLimitDesc != nil {
94+
outputAnnotations.WithRateLimiting(rateLimitDesc)
95+
}
96+
if err != nil {
97+
return outputAnnotations, fmt.Errorf("error validating token with GetCurrentlyAuthenticatedUser: %w", err)
11198
}
99+
/* // Logic for GitLab Cloud.
100+
if d.client.AccountCreationGroup != "" {
101+
// If an account creation group is set, validate it exists and is unique.
102+
groupName := d.client.AccountCreationGroup
103+
_, rateLimitDesc, err := d.client.FindGroupByName(ctx, groupName)
104+
if rateLimitDesc != nil {
105+
outputAnnotations.WithRateLimiting(rateLimitDesc)
106+
}
107+
if err != nil {
108+
return outputAnnotations, fmt.Errorf("failed to validate account creation group: %w", err)
109+
}
110+
} else {
111+
// If no account creation group is set, perform a general token validation.
112+
_, rateLimitDesc, err := d.client.GetCurrentlyAuthenticatedUser(ctx)
113+
if rateLimitDesc != nil {
114+
outputAnnotations.WithRateLimiting(rateLimitDesc)
115+
}
116+
if err != nil {
117+
return outputAnnotations, fmt.Errorf("error validating token with GetCurrentlyAuthenticatedUser: %w", err)
118+
}
119+
}*/
112120
} else {
113121
// For On-Premise, validate the token can list users (requires admin permissions).
114122
_, _, rateLimitDesc, err := d.client.ListUsers(ctx, "")

0 commit comments

Comments
 (0)