Esempio n. 1
0
// AuthenticatorsFor gets the authenticators for the specified security schemes
func (o *TaskTrackerAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]httpkit.Authenticator {

	result := make(map[string]httpkit.Authenticator)
	for name, scheme := range schemes {
		switch name {

		case "token_header":

			result[name] = security.APIKeyAuth(scheme.Name, scheme.In, func(tok string) (interface{}, error) { return o.TokenHeaderAuth(tok) })

		case "api_key":

			result[name] = security.APIKeyAuth(scheme.Name, scheme.In, func(tok string) (interface{}, error) { return o.APIKeyAuth(tok) })

		}
	}
	return result

}
Esempio n. 2
0
// AuthenticatorsFor gets the authenticators for the specified security schemes
func (o *ToDoListAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]httpkit.Authenticator {

	result := make(map[string]httpkit.Authenticator)
	for name, scheme := range schemes {
		switch name {

		case "x-petstore-token":

			result[name] = security.APIKeyAuth(scheme.Name, scheme.In, func(tok string) (interface{}, error) { return o.XPetstoreTokenAuth(tok) })

		}
	}
	return result

}
Esempio n. 3
0
// AuthenticatorsFor gets the authenticators for the specified security schemes
func (s *SwaggerPetstoreAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]httpkit.Authenticator {

	result := make(map[string]httpkit.Authenticator)
	for name, scheme := range schemes {
		switch name {

		case "apiKey":

			result[name] = security.APIKeyAuth(scheme.Name, scheme.In, func(tok string) (interface{}, error) { return s.APIKeyAuth(tok) })

		}
	}
	return result

}