Skip to content

Commit

Permalink
change string to []byte
Browse files Browse the repository at this point in the history
Signed-off-by: huabing zhao <[email protected]>
  • Loading branch information
zhaohuabing committed Nov 23, 2023
1 parent c6e6830 commit c2b407f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/gatewayapi/securitypolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,5 +591,5 @@ func (t *Translator) buildBasicAuth(
return nil, err
}

return &ir.BasicAuth{Users: string(usersSecretBytes)}, nil
return &ir.BasicAuth{Users: usersSecretBytes}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ xdsIR:
invalid: 0
valid: 0
basicAuth:
users: |
user1:{SHA}tESsBmE/yNY3lb6a0L6vVQEZNqw=
user2:{SHA}EJ9LPFDXsN9ynSmbxvjp75Bmlx8=
users: "dXNlcjE6e1NIQX10RVNzQm1FL3lOWTNsYjZhMEw2dlZRRVpOcXc9CnVzZXIyOntTSEF9RUo5TFBGRFhzTjl5blNtYnh2anA3NUJtbHg4PQo="
destination:
name: httproute/default/httproute-1/rule/0
settings:
Expand Down
4 changes: 2 additions & 2 deletions internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (x Xds) Printable() *Xds {
route.OIDC.ClientSecret = []byte{}
}
if route.BasicAuth != nil {
route.BasicAuth.Users = ""
route.BasicAuth.Users = []byte{}
}
}
}
Expand Down Expand Up @@ -365,7 +365,7 @@ type OIDC struct {
// +k8s:deepcopy-gen=true
type BasicAuth struct {
// The username-password pairs in htpasswd format.
Users string `json:"users,omitempty" yaml:"users,omitempty"`
Users []byte `json:"users,omitempty" yaml:"users,omitempty"`
}

type OIDCProvider struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/translator/basicauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func basicAuthConfig(route *ir.HTTPRoute) *basicauthv3.BasicAuth {
return &basicauthv3.BasicAuth{
Users: &corev3.DataSource{
Specifier: &corev3.DataSource_InlineBytes{
InlineBytes: []byte(route.BasicAuth.Users),
InlineBytes: route.BasicAuth.Users,
},
},
}
Expand Down
4 changes: 1 addition & 3 deletions internal/xds/translator/testdata/in/xds-ir/basic-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ http:
- host: "1.2.3.4"
port: 50000
basicAuth:
users: |-
user1:{SHA}hashed_user1_password
user2:{SHA}hashed_user2_password
users: "dXNlcjE6e1NIQX10RVNzQm1FL3lOWTNsYjZhMEw2dlZRRVpOcXc9CnVzZXIyOntTSEF9RUo5TFBGRFhzTjl5blNtYnh2anA3NUJtbHg4PQo="
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.basic_auth.v3.BasicAuth
users:
inlineBytes: dXNlcjE6e1NIQX1oYXNoZWRfdXNlcjFfcGFzc3dvcmQKdXNlcjI6e1NIQX1oYXNoZWRfdXNlcjJfcGFzc3dvcmQ=
inlineBytes: dXNlcjE6e1NIQX10RVNzQm1FL3lOWTNsYjZhMEw2dlZRRVpOcXc9CnVzZXIyOntTSEF9RUo5TFBGRFhzTjl5blNtYnh2anA3NUJtbHg4PQo=
- name: envoy.filters.http.router
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
Expand Down

0 comments on commit c2b407f

Please sign in to comment.