Esempio n. 1
0
// Valid ...
func (r *RepTarget) Valid(v *validation.Validation) {
	if len(r.Name) == 0 {
		v.SetError("name", "can not be empty")
	}

	if len(r.Name) > 64 {
		v.SetError("name", "max length is 64")
	}

	if len(r.URL) == 0 {
		v.SetError("endpoint", "can not be empty")
	}

	r.URL = utils.FormatEndpoint(r.URL)

	if len(r.URL) > 64 {
		v.SetError("endpoint", "max length is 64")
	}

	// password is encoded using base64, the length of this field
	// in DB is 64, so the max length in request is 48
	if len(r.Password) > 48 {
		v.SetError("password", "max length is 48")
	}
}
Esempio n. 2
0
// NewAuthorizerStore ...
func NewAuthorizerStore(endpoint string, insecure bool, authorizers ...Authorizer) (*AuthorizerStore, error) {
	endpoint = utils.FormatEndpoint(endpoint)

	client := &http.Client{
		Transport: registry.GetHTTPTransport(insecure),
		Timeout:   30 * time.Second,
	}

	resp, err := client.Get(buildPingURL(endpoint))
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	challenges := ParseChallengeFromResponse(resp)
	return &AuthorizerStore{
		authorizers: authorizers,
		challenges:  challenges,
	}, nil
}