pomerium/pkg/grpc/identity/identity.go
Caleb Doxsey f9b95a276b
authenticate: support for per-route client id and client secret (#3030)
* implement dynamic provider support

* authenticate: support per-route client id and secret
2022-02-16 12:31:55 -07:00

27 lines
610 B
Go

// Package identity contains protobuf types for identity management.
package identity
import (
"crypto/sha256"
"google.golang.org/protobuf/proto"
"github.com/pomerium/pomerium/pkg/encoding/base58"
)
// Clone clones the Provider.
func (x *Provider) Clone() *Provider {
return proto.Clone(x).(*Provider)
}
// Hash computes a sha256 hash of the provider's fields. It excludes the Id field.
func (x *Provider) Hash() string {
tmp := x.Clone()
tmp.Id = ""
bs, _ := proto.MarshalOptions{
AllowPartial: true,
Deterministic: true,
}.Marshal(tmp)
h := sha256.Sum256(bs)
return base58.Encode(h[:])
}