MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / Validate

Method Validate

config/auth.go:538–559  ·  view source on GitHub ↗

Validate checks if the redirect server configuration is valid. Particularly, it checks the HTTP server parameters as well as if the webroot is valid and contains an index.html.

()

Source from the content-addressed store, hash-verified

536// Validate checks if the redirect server configuration is valid. Particularly, it checks the HTTP server
537// parameters as well as if the webroot is valid and contains an index.html.
538func (o OAuth2RedirectConfig) Validate() error {
539 if err := o.HTTPServerConfiguration.Validate(); err != nil {
540 return err
541 }
542 if o.Webroot != "" {
543 webrootStat, err := os.Stat(o.Webroot)
544 if err != nil {
545 return wrap(err, "webroot")
546 }
547 if !webrootStat.IsDir() {
548 return newError("webroot", "invalid webroot (not a directory)")
549 }
550 indexStat, err := os.Stat(path.Join(o.Webroot, "index.html"))
551 if err != nil {
552 return wrapWithMessage(err, "webroot", "webroot does not contain an index.html file")
553 }
554 if indexStat.IsDir() {
555 return newError("webroot", "webroot does not contain an index.html file (index.html is a directory)")
556 }
557 }
558 return nil
559}
560
561// AuthGitHubConfig is the configuration structure for GitHub authentication.
562type AuthGitHubConfig struct {

Callers

nothing calls this directly

Calls 4

wrapFunction · 0.85
newErrorFunction · 0.85
wrapWithMessageFunction · 0.85
ValidateMethod · 0.65

Tested by

no test coverage detected