mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
Allow auto registration of machines in LAPI (#3202)
Co-authored-by: marco <marco@crowdsec.net>
This commit is contained in:
parent
8c0c10cd7a
commit
d2616766de
17 changed files with 548 additions and 173 deletions
|
@ -27,6 +27,11 @@ type WatcherRegistrationRequest struct {
|
|||
// Required: true
|
||||
// Format: password
|
||||
Password *strfmt.Password `json:"password"`
|
||||
|
||||
// registration token
|
||||
// Max Length: 255
|
||||
// Min Length: 32
|
||||
RegistrationToken string `json:"registration_token,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this watcher registration request
|
||||
|
@ -41,6 +46,10 @@ func (m *WatcherRegistrationRequest) Validate(formats strfmt.Registry) error {
|
|||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRegistrationToken(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
|
@ -69,6 +78,22 @@ func (m *WatcherRegistrationRequest) validatePassword(formats strfmt.Registry) e
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *WatcherRegistrationRequest) validateRegistrationToken(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.RegistrationToken) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.MinLength("registration_token", "body", m.RegistrationToken, 32); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.MaxLength("registration_token", "body", m.RegistrationToken, 255); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this watcher registration request based on context it is used
|
||||
func (m *WatcherRegistrationRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue