mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 10:26:29 +02:00
proxy: Add user dashboard. [GH-123] proxy/authenticate: Add manual refresh of their session. [GH-73] authorize: Add administrator (super user) account support. [GH-110] internal/policy: Allow administrators to impersonate other users. [GH-110]
32 lines
1 KiB
Go
32 lines
1 KiB
Go
//go:generate protoc -I ../proto/authorize --go_out=plugins=grpc:../proto/authorize ../proto/authorize/authorize.proto
|
|
|
|
package authorize // import "github.com/pomerium/pomerium/authorize"
|
|
import (
|
|
"context"
|
|
|
|
pb "github.com/pomerium/pomerium/proto/authorize"
|
|
)
|
|
|
|
// Authorize validates the user identity, device, and context of a request for
|
|
// a given route. Currently only checks identity.
|
|
func (a *Authorize) Authorize(ctx context.Context, in *pb.Identity) (*pb.AuthorizeReply, error) {
|
|
ok := a.ValidIdentity(in.Route,
|
|
&Identity{
|
|
User: in.User,
|
|
Email: in.Email,
|
|
Groups: in.Groups,
|
|
ImpersonateEmail: in.ImpersonateEmail,
|
|
ImpersonateGroups: in.ImpersonateGroups,
|
|
})
|
|
return &pb.AuthorizeReply{IsValid: ok}, nil
|
|
}
|
|
|
|
// IsAdmin validates the user is an administrative user.
|
|
func (a *Authorize) IsAdmin(ctx context.Context, in *pb.Identity) (*pb.IsAdminReply, error) {
|
|
ok := a.identityAccess.IsAdmin(
|
|
&Identity{
|
|
Email: in.Email,
|
|
Groups: in.Groups,
|
|
})
|
|
return &pb.IsAdminReply{IsAdmin: ok}, nil
|
|
}
|