Co-authored-by: Todd Knight <T.Alan.Knight@gmail.com> Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com> Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
67 lines
1.9 KiB
Go
67 lines
1.9 KiB
Go
package request
|
|
|
|
import "github.com/hashicorp/boundary/internal/errors"
|
|
|
|
// Validate the request.State
|
|
func (s *State) Validate() error {
|
|
const op = "request.(State).Validate"
|
|
if s == nil {
|
|
return errors.New(errors.InvalidParameter, op, "missing state")
|
|
}
|
|
if s.TokenRequestId == "" {
|
|
return errors.New(errors.InvalidParameter, op, "missing token request id")
|
|
}
|
|
if s.CreateTime == nil {
|
|
return errors.New(errors.InvalidParameter, op, "missing create time")
|
|
}
|
|
if s.ExpirationTime == nil {
|
|
return errors.New(errors.InvalidParameter, op, "missing expiration time")
|
|
}
|
|
if s.FinalRedirectUrl == "" {
|
|
return errors.New(errors.InvalidParameter, op, "missing final redirect URL")
|
|
}
|
|
if s.Nonce == "" {
|
|
return errors.New(errors.InvalidParameter, op, "missing nonce")
|
|
}
|
|
if s.ProviderConfigHash == 0 {
|
|
return errors.New(errors.InvalidParameter, op, "missing provider config hash")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Validate the request.Wrapper
|
|
func (w *Wrapper) Validate() error {
|
|
const op = "request.(Wrapper).Validate"
|
|
if w == nil {
|
|
return errors.New(errors.InvalidParameter, op, "missing wrapper")
|
|
}
|
|
if w.AuthMethodId == "" {
|
|
return errors.New(errors.InvalidParameter, op, "missing auth method id")
|
|
}
|
|
if w.ScopeId == "" {
|
|
return errors.New(errors.InvalidParameter, op, "missing scope id")
|
|
}
|
|
if w.WrapperKeyId == "" {
|
|
return errors.New(errors.InvalidParameter, op, "missing wrapper key id")
|
|
}
|
|
if len(w.Ct) == 0 {
|
|
return errors.New(errors.InvalidParameter, op, "missing ct")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Validate the request.Token
|
|
func (t *Token) Validate() error {
|
|
const op = "request.(Token).Validate"
|
|
if t == nil {
|
|
return errors.New(errors.InvalidParameter, op, "missing token")
|
|
}
|
|
if t.RequestId == "" {
|
|
return errors.New(errors.InvalidParameter, op, "missing request id")
|
|
}
|
|
if t.ExpirationTime == nil {
|
|
return errors.New(errors.InvalidParameter, op, "missing expiration time")
|
|
}
|
|
return nil
|
|
}
|