// Validate checks to see if configuration values are valid for the
// authorize service. Returns first error, if found.
Validate checks to see if configuration values are valid for the
authorize service. Returns first error, if found.
// Validate checks to see if configuration values are valid for the // authorize service . Returns first error if found .
func (o *Options) Validate() error {
	decoded, err := base64.StdEncoding.DecodeString(o.SharedKey)
	if err != nil {
		return fmt.Errorf("authorize: `SHARED_SECRET` setting is invalid base64: %v", err)
	}
	if len(decoded) != 32 {
		return fmt.Errorf("authorize: `SHARED_SECRET` want 32 but got %d bytes", len(decoded))
	}
	if o.Policy == "" && o.PolicyFile == "" {
		return errors.New("authorize: either `POLICY` or `POLICY_FILE` must be non-nil")
	}
	if o.Policy != "" {
		confBytes, err := base64.StdEncoding.DecodeString(o.Policy)
		if err != nil {
			return fmt.Errorf("authorize: `POLICY` is invalid base64 %v", err)
		}
		_, err = policy.FromConfig(confBytes)
		if err != nil {
			return fmt.Errorf("authorize: `POLICY` %v", err)
		}
	}
	if o.PolicyFile != "" {
		_, err = policy.FromConfigFile(o.PolicyFile)
		if err != nil {
			return fmt.Errorf("authorize: `POLICY_FILE` %v", err)
		}
	}
	return nil
}
func ( o * Options ) Validate ( ) error { decoded , err := base64 . StdEncoding . DecodeString ( o . SharedKey ) if err != nil { return fmt . Errorf ( " " , err ) } if len ( decoded ) != 32 { return fmt . Errorf ( " " , len ( decoded ) ) } if o . Policy == " " && o . PolicyFile == " " { return errors . New ( " " ) } if o . Policy != " " { confBytes , err := base64 . StdEncoding . DecodeString ( o . Policy ) if err != nil { return fmt . Errorf ( " " , err ) } _ , err = policy . FromConfig ( confBytes ) if err != nil { return fmt . Errorf ( " " , err ) } } if o . PolicyFile != " " { _ , err = policy . FromConfigFile ( o . PolicyFile ) if err != nil { return fmt . Errorf ( " " , err ) } } return nil }
Validate checks to see if configuration values are valid for the
authorize service.
Validate checks to see if configuration values are valid for the authorize service .