Skip to content
This repository has been archived by the owner on Dec 20, 2022. It is now read-only.

verify config.Proxy during startup #51

Closed
WindzCUHK opened this issue Apr 8, 2020 · 1 comment
Closed

verify config.Proxy during startup #51

WindzCUHK opened this issue Apr 8, 2020 · 1 comment

Comments

@WindzCUHK
Copy link
Contributor

effect

prevent the proxy get in fatal error during runtime

Director: func(r *http.Request) {
u := *r.URL
u.Scheme = scheme
u.Host = host
req, err := http.NewRequest(r.Method, u.String(), r.Body)
if err != nil {
glg.Fatal(errors.Wrap(err, "NewRequest returned error"))
}
req.Header = r.Header
*r = *req
},

fix

return error if config.Proxy contains invalid values during startup, e.g.

  1. scheme != 'http' || scheme != 'https'
  2. host ~ '@'

// New returns a Authorization Proxy daemon, or error occurred.
// The daemon contains a token service authentication and authorization server.
// This function will also initialize the mapping rules for the authentication and authorization check.
func New(cfg config.Config) (AuthzProxyDaemon, error) {
athenz, err := newAuthzD(cfg)
if err != nil {
return nil, errors.Wrap(err, "cannot newAuthzD(cfg)")
}
debugMux := router.NewDebugRouter(cfg.Server, athenz)
return &authzProxyDaemon{
cfg: cfg,
athenz: athenz,
server: service.NewServer(
service.WithServerConfig(cfg.Server),
service.WithServerHandler(handler.New(cfg.Proxy, infra.NewBuffer(cfg.Proxy.BufferSize), athenz)),
service.WithDebugHandler(debugMux)),
}, nil
}

@WindzCUHK
Copy link
Contributor Author

continue in: AthenZ/authorization-proxy#11

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant