Skip to content

Commit

Permalink
Add First and Last name to the user identity object
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslav Dimitrov <[email protected]>
  • Loading branch information
rdimitrov committed Jul 10, 2024
1 parent 33d7744 commit 88b83d0
Show file tree
Hide file tree
Showing 8 changed files with 1,040 additions and 975 deletions.
2 changes: 2 additions & 0 deletions docs/docs/ref/proto.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/auth/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ type Identity struct {
// UserID and HumanName are only unique within the context of a single
// identity provider.
Provider IdentityProvider
// FirstName and LastName are optional fields that may be provided by the
// identity provider. These are not guaranteed to be present, and may be
// empty.
FirstName string
LastName string
}

// String implements strings.Stringer, and also provides a stable storage
Expand Down
10 changes: 9 additions & 1 deletion internal/auth/keycloak/keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,19 @@ func (k *KeyCloak) userToIdentity(user client.UserRepresentation) *auth.Identity
if user.Attributes == nil || user.Id == nil {
return nil
}
return &auth.Identity{
ret := &auth.Identity{
UserID: *user.Id,
HumanName: *user.Username,
Provider: k,
}
// If the user has a first and last name, return them too
if user.FirstName != nil {
ret.FirstName = *user.FirstName
}
if user.LastName != nil {
ret.LastName = *user.LastName
}
return ret
}

func (_ *KeyCloak) lookupGithubUser(_ context.Context, _ string) (*auth.Identity, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/authz/model/minder.generated.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/controlplane/handlers_authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ func (s *Server) ListRoleAssignments(
continue
}
as[i].DisplayName = identity.Human()
as[i].FirstName = identity.FirstName
as[i].LastName = identity.LastName
if mapIdToDisplay[as[i].Subject] == "" {
mapIdToDisplay[as[i].Subject] = identity.Human()
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/api/openapi/minder/v1/minder.swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 88b83d0

Please sign in to comment.