// Code generated by goa v3.6.0, DO NOT EDIT. // // Service1 service // // Command: // $ goa gen goa_example/design package service1 import ( "context" "goa.design/goa/v3/security" ) // The secured service exposes endpoints that require valid authorization // credentials. type Service interface { // Signin implements signin. Signin(context.Context, *SigninPayload) (res *Creds, err error) // 这是一个需要JWT认证的接口 Secure(context.Context, *SecurePayload) (res string, err error) } // Auther defines the authorization functions to be implemented by the service. type Auther interface { // BasicAuth implements the authorization logic for the Basic security scheme. BasicAuth(ctx context.Context, user, pass string, schema *security.BasicScheme) (context.Context, error) // JWTAuth implements the authorization logic for the JWT security scheme. JWTAuth(ctx context.Context, token string, schema *security.JWTScheme) (context.Context, error) } // ServiceName is the name of the service as defined in the design. This is the // same value that is set in the endpoint request contexts under the ServiceKey // key. const ServiceName = "Service1" // MethodNames lists the service method names as defined in the design. These // are the same values that are set in the endpoint request contexts under the // MethodKey key. var MethodNames = [2]string{"signin", "secure"} // Creds is the result type of the Service1 service signin method. type Creds struct { // JWT token JWT string // API Key APIKey string // OAuth2 token OauthToken string } // SecurePayload is the payload type of the Service1 service secure method. type SecurePayload struct { // Whether to force auth failure even with a valid JWT Fail *bool // JWT used for authentication Token string } // Credentials used to authenticate to retrieve JWT token type SigninPayload struct { // Username used to perform signin Username string // Password used to perform signin Password string } // Credentials are invalid type Unauthorized string // Error returns an error description. func (e Unauthorized) Error() string { return "Credentials are invalid" } // ErrorName returns "unauthorized". func (e Unauthorized) ErrorName() string { return "unauthorized" }