mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-30 15:00:51 +02:00
authorize: populate issuer even when policy is nil (#4211)
This commit is contained in:
parent
6efd1d6bc9
commit
578507d5fe
2 changed files with 8 additions and 1 deletions
|
@ -30,11 +30,11 @@ type HeadersRequest struct {
|
|||
// NewHeadersRequestFromPolicy creates a new HeadersRequest from a policy.
|
||||
func NewHeadersRequestFromPolicy(policy *config.Policy, hostname string) *HeadersRequest {
|
||||
input := new(HeadersRequest)
|
||||
input.Issuer = hostname
|
||||
if policy != nil {
|
||||
input.EnableGoogleCloudServerlessAuthentication = policy.EnableGoogleCloudServerlessAuthentication
|
||||
input.EnableRoutingKey = policy.EnvoyOpts.GetLbPolicy() == envoy_config_cluster_v3.Cluster_RING_HASH ||
|
||||
policy.EnvoyOpts.GetLbPolicy() == envoy_config_cluster_v3.Cluster_MAGLEV
|
||||
input.Issuer = hostname
|
||||
input.KubernetesServiceAccountToken = policy.KubernetesServiceAccountToken
|
||||
for _, wu := range policy.To {
|
||||
input.ToAudience = "https://" + wu.URL.Hostname()
|
||||
|
|
|
@ -36,6 +36,13 @@ func TestNewHeadersRequestFromPolicy(t *testing.T) {
|
|||
}, req)
|
||||
}
|
||||
|
||||
func TestNewHeadersRequestFromPolicy_nil(t *testing.T) {
|
||||
req := NewHeadersRequestFromPolicy(nil, "from.example.com")
|
||||
assert.Equal(t, &HeadersRequest{
|
||||
Issuer: "from.example.com",
|
||||
}, req)
|
||||
}
|
||||
|
||||
func TestHeadersEvaluator(t *testing.T) {
|
||||
type A = []interface{}
|
||||
type M = map[string]interface{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue