mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-02 10:52:49 +02:00
config: add route name, description and logo (#5424)
* config: add route name, description and logo * remove name generation
This commit is contained in:
parent
dfd2457bb6
commit
8bc86fe06f
4 changed files with 808 additions and 770 deletions
|
@ -27,7 +27,10 @@ import (
|
||||||
|
|
||||||
// Policy contains route specific configuration and access settings.
|
// Policy contains route specific configuration and access settings.
|
||||||
type Policy struct {
|
type Policy struct {
|
||||||
ID string `mapstructure:"-" yaml:"-" json:"-"`
|
ID string `mapstructure:"-" yaml:"-" json:"-"`
|
||||||
|
Name string `mapstructure:"-" yaml:"-" json:"-"`
|
||||||
|
Description string `mapstructure:"description" yaml:"description,omitempty" json:"description,omitempty"`
|
||||||
|
LogoURL string `mapstructure:"logo_url" yaml:"logo_url,omitempty" json:"logo_url,omitempty"`
|
||||||
|
|
||||||
From string `mapstructure:"from" yaml:"from"`
|
From string `mapstructure:"from" yaml:"from"`
|
||||||
To WeightedURLs `mapstructure:"to" yaml:"to"`
|
To WeightedURLs `mapstructure:"to" yaml:"to"`
|
||||||
|
@ -285,6 +288,7 @@ func NewPolicyFromProto(pb *configpb.Route) (*Policy, error) {
|
||||||
AllowSPDY: pb.GetAllowSpdy(),
|
AllowSPDY: pb.GetAllowSpdy(),
|
||||||
AllowWebsockets: pb.GetAllowWebsockets(),
|
AllowWebsockets: pb.GetAllowWebsockets(),
|
||||||
CORSAllowPreflight: pb.GetCorsAllowPreflight(),
|
CORSAllowPreflight: pb.GetCorsAllowPreflight(),
|
||||||
|
Description: pb.GetDescription(),
|
||||||
EnableGoogleCloudServerlessAuthentication: pb.GetEnableGoogleCloudServerlessAuthentication(),
|
EnableGoogleCloudServerlessAuthentication: pb.GetEnableGoogleCloudServerlessAuthentication(),
|
||||||
From: pb.GetFrom(),
|
From: pb.GetFrom(),
|
||||||
HostPathRegexRewritePattern: pb.GetHostPathRegexRewritePattern(),
|
HostPathRegexRewritePattern: pb.GetHostPathRegexRewritePattern(),
|
||||||
|
@ -298,6 +302,8 @@ func NewPolicyFromProto(pb *configpb.Route) (*Policy, error) {
|
||||||
JWTGroupsFilter: NewJWTGroupsFilter(pb.JwtGroupsFilter),
|
JWTGroupsFilter: NewJWTGroupsFilter(pb.JwtGroupsFilter),
|
||||||
KubernetesServiceAccountToken: pb.GetKubernetesServiceAccountToken(),
|
KubernetesServiceAccountToken: pb.GetKubernetesServiceAccountToken(),
|
||||||
KubernetesServiceAccountTokenFile: pb.GetKubernetesServiceAccountTokenFile(),
|
KubernetesServiceAccountTokenFile: pb.GetKubernetesServiceAccountTokenFile(),
|
||||||
|
LogoURL: pb.GetLogoUrl(),
|
||||||
|
Name: pb.GetName(),
|
||||||
PassIdentityHeaders: pb.PassIdentityHeaders,
|
PassIdentityHeaders: pb.PassIdentityHeaders,
|
||||||
Path: pb.GetPath(),
|
Path: pb.GetPath(),
|
||||||
Prefix: pb.GetPrefix(),
|
Prefix: pb.GetPrefix(),
|
||||||
|
@ -438,6 +444,7 @@ func (p *Policy) ToProto() (*configpb.Route, error) {
|
||||||
AllowSpdy: p.AllowSPDY,
|
AllowSpdy: p.AllowSPDY,
|
||||||
AllowWebsockets: p.AllowWebsockets,
|
AllowWebsockets: p.AllowWebsockets,
|
||||||
CorsAllowPreflight: p.CORSAllowPreflight,
|
CorsAllowPreflight: p.CORSAllowPreflight,
|
||||||
|
Description: p.Description,
|
||||||
EnableGoogleCloudServerlessAuthentication: p.EnableGoogleCloudServerlessAuthentication,
|
EnableGoogleCloudServerlessAuthentication: p.EnableGoogleCloudServerlessAuthentication,
|
||||||
EnvoyOpts: p.EnvoyOpts,
|
EnvoyOpts: p.EnvoyOpts,
|
||||||
From: p.From,
|
From: p.From,
|
||||||
|
@ -446,7 +453,8 @@ func (p *Policy) ToProto() (*configpb.Route, error) {
|
||||||
JwtGroupsFilter: p.JWTGroupsFilter.ToSlice(),
|
JwtGroupsFilter: p.JWTGroupsFilter.ToSlice(),
|
||||||
KubernetesServiceAccountToken: p.KubernetesServiceAccountToken,
|
KubernetesServiceAccountToken: p.KubernetesServiceAccountToken,
|
||||||
KubernetesServiceAccountTokenFile: p.KubernetesServiceAccountTokenFile,
|
KubernetesServiceAccountTokenFile: p.KubernetesServiceAccountTokenFile,
|
||||||
Name: fmt.Sprint(p.RouteID()),
|
LogoUrl: p.LogoURL,
|
||||||
|
Name: p.Name,
|
||||||
PassIdentityHeaders: p.PassIdentityHeaders,
|
PassIdentityHeaders: p.PassIdentityHeaders,
|
||||||
Path: p.Path,
|
Path: p.Path,
|
||||||
Policies: sps,
|
Policies: sps,
|
||||||
|
@ -476,6 +484,9 @@ func (p *Policy) ToProto() (*configpb.Route, error) {
|
||||||
TlsUpstreamAllowRenegotiation: p.TLSUpstreamAllowRenegotiation,
|
TlsUpstreamAllowRenegotiation: p.TLSUpstreamAllowRenegotiation,
|
||||||
TlsUpstreamServerName: p.TLSUpstreamServerName,
|
TlsUpstreamServerName: p.TLSUpstreamServerName,
|
||||||
}
|
}
|
||||||
|
if pb.Name == "" {
|
||||||
|
pb.Name = fmt.Sprint(p.RouteID())
|
||||||
|
}
|
||||||
if p.HostPathRegexRewritePattern != "" {
|
if p.HostPathRegexRewritePattern != "" {
|
||||||
pb.HostPathRegexRewritePattern = proto.String(p.HostPathRegexRewritePattern)
|
pb.HostPathRegexRewritePattern = proto.String(p.HostPathRegexRewritePattern)
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,9 @@ func TestPolicy_FromToPb(t *testing.T) {
|
||||||
|
|
||||||
t.Run("normal", func(t *testing.T) {
|
t.Run("normal", func(t *testing.T) {
|
||||||
p := &Policy{
|
p := &Policy{
|
||||||
|
Name: "ROUTE_NAME",
|
||||||
|
Description: "DESCRIPTION",
|
||||||
|
LogoURL: "LOGO_URL",
|
||||||
From: "https://pomerium.io",
|
From: "https://pomerium.io",
|
||||||
To: mustParseWeightedURLs(t, "http://localhost"),
|
To: mustParseWeightedURLs(t, "http://localhost"),
|
||||||
AllowedUsers: []string{"foo@bar.com"},
|
AllowedUsers: []string{"foo@bar.com"},
|
||||||
|
@ -235,6 +238,9 @@ func TestPolicy_FromToPb(t *testing.T) {
|
||||||
|
|
||||||
policyFromPb, err := NewPolicyFromProto(pbPolicy)
|
policyFromPb, err := NewPolicyFromProto(pbPolicy)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, p.Name, policyFromPb.Name)
|
||||||
|
assert.Equal(t, p.Description, policyFromPb.Description)
|
||||||
|
assert.Equal(t, p.LogoURL, policyFromPb.LogoURL)
|
||||||
assert.Equal(t, p.From, policyFromPb.From)
|
assert.Equal(t, p.From, policyFromPb.From)
|
||||||
assert.Equal(t, p.To, policyFromPb.To)
|
assert.Equal(t, p.To, policyFromPb.To)
|
||||||
assert.Equal(t, p.AllowedUsers, policyFromPb.AllowedUsers)
|
assert.Equal(t, p.AllowedUsers, policyFromPb.AllowedUsers)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -45,9 +45,11 @@ enum IssuerFormat {
|
||||||
IssuerURI = 1;
|
IssuerURI = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next ID: 67.
|
// Next ID: 69.
|
||||||
message Route {
|
message Route {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
|
string description = 67;
|
||||||
|
string logo_url = 68;
|
||||||
|
|
||||||
string from = 2;
|
string from = 2;
|
||||||
repeated string to = 3;
|
repeated string to = 3;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue