Skip to content

Commit

Permalink
Moving empty name logic to google client
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPates committed Jun 20, 2024
1 parent ed26e47 commit 7c54533
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 0 additions & 9 deletions internal/aws/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ func NewUser(firstName string, lastName string, email string, active bool) *User
Type: "work",
})

// This handles the rare occation where these field are populated with a zero width space
// IAM Identity Center will reject.
if firstName == string('​') {
firstName = " "
}
if lastName == string('​') {
lastName = " "
}

return &User{
Schemas: []string{"urn:ietf:params:scim:schemas:core:2.0:User"},
Username: email,
Expand Down
14 changes: 14 additions & 0 deletions internal/google/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ func (c *client) GetUsers(query string) ([]*admin.User, error) {
}
}

// some people prefer to go by a mononym
// Google directory will accept a 'zero width space' for an empty name but will not accept a 'space'
// but
// Identity Store will accept and a 'space' for an empty name but not a 'zero width space'
// So we need to replace any 'zero width space' strings with a single 'space' to allow comparison and sync
for _, user := range u {
if user.Name.GivenName == string('<200b>') {

Check failure on line 137 in internal/google/client.go

View workflow job for this annotation

GitHub Actions / test

more than one character in rune literal
user.Name.GivenName = " "
}
if user.Name.FamilyName == string('<200b>') {

Check failure on line 140 in internal/google/client.go

View workflow job for this annotation

GitHub Actions / test

more than one character in rune literal (compile)
user.Name.FamilyName = " "
}
}

// Check we've got some users otherwise something is wrong.
if len(u) == 0 {
return u, errors.New("google api returned 0 users?")
Expand Down

0 comments on commit 7c54533

Please sign in to comment.