Skip to content

Commit

Permalink
Add First and Last name to the user identity object (#3832)
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslav Dimitrov <[email protected]>
  • Loading branch information
rdimitrov authored Jul 10, 2024
1 parent 881c672 commit 3931da3
Show file tree
Hide file tree
Showing 7 changed files with 1,039 additions and 974 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: 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.

1,968 changes: 995 additions & 973 deletions pkg/api/protobuf/go/minder/v1/minder.pb.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions proto/minder/v1/minder.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,10 @@ message RoleAssignment {
optional string project = 4;
// email is the email address of the subject used for invitations.
string email = 6;
// first_name is the first name of the subject.
string first_name = 7;
// last_name is the last name of the subject.
string last_name = 8;

reserved 3; // deprecated context
}
Expand Down

0 comments on commit 3931da3

Please sign in to comment.