mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-10 07:37:33 +02:00
fix redirect loop, remove user/session services, remove duplicate deleted_at fields (#1162)
* fix redirect loop, remove user/session services, remove duplicate deleted_at fields * change loop * reuse err variable * wrap errors, use cookie timeout * wrap error, duplicate if
This commit is contained in:
parent
714363fb07
commit
97f85481f8
16 changed files with 288 additions and 918 deletions
|
@ -3,8 +3,10 @@ package user
|
|||
|
||||
import (
|
||||
context "context"
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/protoutil"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
|
@ -19,13 +21,13 @@ func Get(ctx context.Context, client databroker.DataBrokerServiceClient, userID
|
|||
Id: userID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error getting user from databroker: %w", err)
|
||||
}
|
||||
|
||||
var u User
|
||||
err = ptypes.UnmarshalAny(res.GetRecord().GetData(), &u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error unmarshaling user from databroker: %w", err)
|
||||
}
|
||||
return &u, nil
|
||||
}
|
||||
|
@ -34,3 +36,17 @@ func Get(ctx context.Context, client databroker.DataBrokerServiceClient, userID
|
|||
func (user *User) GetClaim(claim string) interface{} {
|
||||
return protoutil.AnyToInterface(user.GetClaims()[claim])
|
||||
}
|
||||
|
||||
// Set sets a user in the databroker.
|
||||
func Set(ctx context.Context, client databroker.DataBrokerServiceClient, u *User) (*databroker.Record, error) {
|
||||
any, _ := anypb.New(u)
|
||||
res, err := client.Set(ctx, &databroker.SetRequest{
|
||||
Type: any.GetTypeUrl(),
|
||||
Id: u.Id,
|
||||
Data: any,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error setting user in databroker: %w", err)
|
||||
}
|
||||
return res.GetRecord(), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue