mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-02 03:46:29 +02:00
* refactor backend, implement encrypted store * refactor in-memory store * wip * wip * wip * add syncer test * fix redis expiry * fix linting issues * fix test by skipping non-config records * fix backoff import * fix init issues * fix query * wait for initial sync before starting directory sync * add type to SyncLatest * add more log messages, fix deadlock in in-memory store, always return server version from SyncLatest * update sync types and tests * add redis tests * skip macos in github actions * add comments to proto * split getBackend into separate methods * handle errors in initVersion * return different error for not found vs other errors in get * use exponential backoff for redis transaction retry * rename raw to result * use context instead of close channel * store type urls as constants in databroker * use timestampb instead of ptypes * fix group merging not waiting * change locked names * update GetAll to return latest record version * add method to grpcutil to get the type url for a protobuf type
46 lines
981 B
Go
46 lines
981 B
Go
package databroker
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"google.golang.org/protobuf/types/known/anypb"
|
|
"google.golang.org/protobuf/types/known/emptypb"
|
|
|
|
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
|
"github.com/pomerium/pomerium/pkg/grpc/directory"
|
|
)
|
|
|
|
// RefreshUser refreshes a user's directory information.
|
|
func (c *DataBroker) RefreshUser(ctx context.Context, req *directory.RefreshUserRequest) (*emptypb.Empty, error) {
|
|
c.mu.Lock()
|
|
dp := c.directoryProvider
|
|
c.mu.Unlock()
|
|
|
|
if dp == nil {
|
|
return nil, errors.New("no directory provider is available for refresh")
|
|
}
|
|
|
|
u, err := dp.User(ctx, req.GetUserId(), req.GetAccessToken())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
any, err := anypb.New(u)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
_, err = c.dataBrokerServer.Put(ctx, &databroker.PutRequest{
|
|
Record: &databroker.Record{
|
|
Type: any.GetTypeUrl(),
|
|
Id: u.GetId(),
|
|
Data: any,
|
|
},
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return new(emptypb.Empty), nil
|
|
}
|