diff --git a/connector/atlassiancrowd/atlassiancrowd.go b/connector/atlassiancrowd/atlassiancrowd.go index e2ca94b0..6937541a 100644 --- a/connector/atlassiancrowd/atlassiancrowd.go +++ b/connector/atlassiancrowd/atlassiancrowd.go @@ -54,10 +54,11 @@ type Config struct { } type crowdUser struct { - Key string - Name string - Active bool - Email string + Key string + Name string + DisplayName string `json:"display-name"` + Active bool + Email string } type crowdGroups struct { @@ -129,7 +130,7 @@ func (c *crowdConnector) Login(ctx context.Context, s connector.Scopes, username ident = c.identityFromCrowdUser(user) if s.Groups { - userGroups, err := c.getGroups(ctx, client, s.Groups, ident.Username) + userGroups, err := c.getGroups(ctx, client, s.Groups, username) if err != nil { return connector.Identity{}, false, fmt.Errorf("crowd: failed to query groups: %v", err) } @@ -171,7 +172,7 @@ func (c *crowdConnector) Refresh(ctx context.Context, s connector.Scopes, ident } if s.Groups { - userGroups, err := c.getGroups(ctx, client, s.Groups, newIdent.Username) + userGroups, err := c.getGroups(ctx, client, s.Groups, data.Username) if err != nil { return connector.Identity{}, fmt.Errorf("crowd: failed to query groups: %v", err) } @@ -361,7 +362,7 @@ func (c *crowdConnector) groups(ctx context.Context, client *http.Client, userna // identityFromCrowdUser converts crowdUser to Identity func (c *crowdConnector) identityFromCrowdUser(user crowdUser) connector.Identity { identity := connector.Identity{ - Username: user.Name, + Username: user.DisplayName, UserID: user.Key, Email: user.Email, EmailVerified: true, diff --git a/connector/atlassiancrowd/atlassiancrowd_test.go b/connector/atlassiancrowd/atlassiancrowd_test.go index 36789a39..ee0d4b80 100644 --- a/connector/atlassiancrowd/atlassiancrowd_test.go +++ b/connector/atlassiancrowd/atlassiancrowd_test.go @@ -103,10 +103,11 @@ func TestUserPassword(t *testing.T) { func TestIdentityFromCrowdUser(t *testing.T) { user := crowdUser{ - Key: "12345", - Name: "testuser", - Active: true, - Email: "testuser@example.com", + Key: "12345", + Name: "testuser", + DisplayName: "Test User", + Active: true, + Email: "testuser@example.com", } c := newTestCrowdConnector("/") @@ -118,7 +119,7 @@ func TestIdentityFromCrowdUser(t *testing.T) { // Test unconfigured behaviour i := c.identityFromCrowdUser(user) expectEquals(t, i.UserID, "12345") - expectEquals(t, i.Username, "testuser") + expectEquals(t, i.Username, "Test User") expectEquals(t, i.Email, "testuser@example.com") expectEquals(t, i.EmailVerified, true)