mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-30 06:51:30 +02:00
* store directory groups separate from directory users * fix group lookup, azure display name * remove fields restriction * fix test * also support email * use Email as name for google' * remove changed file * show groups on dashboard * fix test * re-add accidentally removed code
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
// Package directory contains protobuf types for directory users.
|
|
package directory
|
|
|
|
import (
|
|
context "context"
|
|
|
|
"github.com/golang/protobuf/ptypes"
|
|
|
|
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
|
)
|
|
|
|
// GetGroup gets a directory group from the databroker.
|
|
func GetGroup(ctx context.Context, client databroker.DataBrokerServiceClient, groupID string) (*Group, error) {
|
|
any, _ := ptypes.MarshalAny(new(Group))
|
|
|
|
res, err := client.Get(ctx, &databroker.GetRequest{
|
|
Type: any.GetTypeUrl(),
|
|
Id: groupID,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var g Group
|
|
err = ptypes.UnmarshalAny(res.GetRecord().GetData(), &g)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &g, nil
|
|
}
|
|
|
|
// GetUser gets a directory user from the databroker.
|
|
func GetUser(ctx context.Context, client databroker.DataBrokerServiceClient, userID string) (*User, error) {
|
|
any, _ := ptypes.MarshalAny(new(User))
|
|
|
|
res, err := client.Get(ctx, &databroker.GetRequest{
|
|
Type: any.GetTypeUrl(),
|
|
Id: userID,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var u User
|
|
err = ptypes.UnmarshalAny(res.GetRecord().GetData(), &u)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &u, nil
|
|
}
|