mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 02:16:28 +02:00
26 lines
594 B
Go
26 lines
594 B
Go
// Package identity contains protobuf types for identity management.
|
|
package identity
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
|
|
"github.com/jxskiss/base62"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 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 base62.EncodeToString(h[:])
|
|
}
|