// New validates and creates a new Authorize service from a set of Options
New validates and creates a new Authorize service from a set of Options
// New validates and creates a new Authorize service from a set of Options
func New(opts *Options) (*Authorize, error) {
	if opts == nil {
		return nil, errors.New("authorize: options cannot be nil")
	}
	if err := opts.Validate(); err != nil {
		return nil, err
	}
	sharedKey, _ := base64.StdEncoding.DecodeString(opts.SharedKey)
	var policies []policy.Policy
	if opts.Policy != "" {
		confBytes, _ := base64.StdEncoding.DecodeString(opts.Policy)
		policies, _ = policy.FromConfig(confBytes)
	} else {
		policies, _ = policy.FromConfigFile(opts.PolicyFile)
	}
	return &Authorize{
		SharedKey:      string(sharedKey),
		identityAccess: NewIdentityWhitelist(policies),
	}, nil
}
func New ( opts * Options ) ( * Authorize , error ) { if opts == nil { return nil , errors . New ( " " ) } if err := opts . Validate ( ) ; err != nil { return nil , err } sharedKey , _ := base64 . StdEncoding . DecodeString ( opts . SharedKey ) var policies [ ] policy . Policy if opts . Policy != " " { confBytes , _ := base64 . StdEncoding . DecodeString ( opts . Policy ) policies , _ = policy . FromConfig ( confBytes ) } else { policies , _ = policy . FromConfigFile ( opts . PolicyFile ) } return & Authorize { SharedKey : string ( sharedKey ) , identityAccess : NewIdentityWhitelist ( policies ) , } , nil }
New validates and creates a new Authorize service from a set of Options
New validates and creates a new Authorize service from a set of Options
// errors handled by validate