mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
refactor: lints
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This commit is contained in:
@@ -2273,7 +2273,7 @@ type Cluster struct {
|
||||
// The embedded metav1.ObjectMeta field is purely here to please the informer when converting from a v1.Secret to a Cluster.
|
||||
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
||||
// +optional
|
||||
metav1.ObjectMeta `json:"-,omitempty"`
|
||||
metav1.ObjectMeta `json:"-"`
|
||||
}
|
||||
|
||||
func (c *Cluster) Sanitized() *Cluster {
|
||||
|
||||
@@ -538,10 +538,10 @@ func SetPermissions(permissions []ACL, username string, roleName string) error {
|
||||
var aclstr strings.Builder
|
||||
|
||||
for _, permission := range permissions {
|
||||
aclstr.WriteString(fmt.Sprintf("p, role:%s, %s, %s, %s, allow \n", roleName, permission.Resource, permission.Action, permission.Scope))
|
||||
fmt.Printf("p, role:%s, %s, %s, %s, allow \n", roleName, permission.Resource, permission.Action, permission.Scope)
|
||||
}
|
||||
|
||||
aclstr.WriteString(fmt.Sprintf("g, %s, role:%s", username, roleName))
|
||||
fmt.Printf("g, %s, role:%s", username, roleName)
|
||||
cm.Data["policy.csv"] = aclstr.String()
|
||||
|
||||
return nil
|
||||
|
||||
@@ -19,13 +19,6 @@ import (
|
||||
"github.com/argoproj/argo-cd/v3/util/errors"
|
||||
)
|
||||
|
||||
func decorateDirector(director func(req *http.Request), target *url.URL) func(req *http.Request) {
|
||||
return func(req *http.Request) {
|
||||
director(req)
|
||||
req.Host = target.Host
|
||||
}
|
||||
}
|
||||
|
||||
type DexTLSConfig struct {
|
||||
DisableTLS bool
|
||||
StrictValidation bool
|
||||
@@ -65,37 +58,40 @@ func NewDexHTTPReverseProxy(serverAddr string, baseHRef string, tlsConfig *DexTL
|
||||
errors.CheckError(err)
|
||||
target.Path = baseHRef
|
||||
|
||||
proxy := httputil.NewSingleHostReverseProxy(target)
|
||||
proxy := &httputil.ReverseProxy{
|
||||
Rewrite: func(r *httputil.ProxyRequest) {
|
||||
r.SetURL(target)
|
||||
r.Out.Host = target.Host
|
||||
},
|
||||
ModifyResponse: func(resp *http.Response) error {
|
||||
if resp.StatusCode == http.StatusInternalServerError {
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = resp.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.WithFields(log.Fields{
|
||||
common.SecurityField: common.SecurityMedium,
|
||||
}).Errorf("received error from dex: %s", string(b))
|
||||
resp.ContentLength = 0
|
||||
resp.Header.Set("Content-Length", strconv.Itoa(0))
|
||||
resp.Header.Set("Location", path.Join(baseHRef, "login")+"?has_sso_error=true")
|
||||
resp.StatusCode = http.StatusSeeOther
|
||||
resp.Body = io.NopCloser(bytes.NewReader(make([]byte, 0)))
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
if tlsConfig != nil && !tlsConfig.DisableTLS {
|
||||
proxy.Transport = &http.Transport{
|
||||
TLSClientConfig: TLSConfig(tlsConfig),
|
||||
}
|
||||
}
|
||||
|
||||
proxy.ModifyResponse = func(resp *http.Response) error {
|
||||
if resp.StatusCode == http.StatusInternalServerError {
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = resp.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.WithFields(log.Fields{
|
||||
common.SecurityField: common.SecurityMedium,
|
||||
}).Errorf("received error from dex: %s", string(b))
|
||||
resp.ContentLength = 0
|
||||
resp.Header.Set("Content-Length", strconv.Itoa(0))
|
||||
resp.Header.Set("Location", path.Join(baseHRef, "login")+"?has_sso_error=true")
|
||||
resp.StatusCode = http.StatusSeeOther
|
||||
resp.Body = io.NopCloser(bytes.NewReader(make([]byte, 0)))
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
proxy.Director = decorateDirector(proxy.Director, target)
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
proxy.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user