mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
30 lines
664 B
Go
30 lines
664 B
Go
// Package session contains protobuf types for sessions.
|
|
package session
|
|
|
|
import (
|
|
context "context"
|
|
|
|
"github.com/golang/protobuf/ptypes"
|
|
|
|
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
|
)
|
|
|
|
// Get gets a session from the databroker.
|
|
func Get(ctx context.Context, client databroker.DataBrokerServiceClient, sessionID string) (*Session, error) {
|
|
any, _ := ptypes.MarshalAny(new(Session))
|
|
|
|
res, err := client.Get(ctx, &databroker.GetRequest{
|
|
Type: any.GetTypeUrl(),
|
|
Id: sessionID,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var s Session
|
|
err = ptypes.UnmarshalAny(res.GetRecord().GetData(), &s)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &s, nil
|
|
}
|