Documentation ¶
Index ¶
- Constants
- Variables
- func AccessToken(store *oauth2.Store) gin.HandlerFunc
- func CORS() gin.HandlerFunc
- func Errors() gin.HandlerFunc
- func LcFirst(str string) string
- func MakeExtraValidation(v []ExtraValidation)
- func OauthMiddleware(store *oauth2.Store) gin.HandlerFunc
- func Split(src string) string
- func UcFirst(str string) string
- func ValidationErrorToText(e validator.FieldError) string
- type AccessTokenPayload
- type ExtraValidation
- type GrantType
- type PasswordCredential
- type Profile
- type RefreshTokenCredential
- type Tokens
Constants ¶
View Source
const ( InvalidClient = "Invalid client credential!" InvalidUser = "Invalid resource owner credential!" InvalidGrantType = "Invalid grant type!" InvalidAccessToken = "Invalid access token!" InvalidScope = "Invalid scope!" EmptyHeader = "Authorization header is not included!" InvalidHeader = "Authorization header is invalid!" RefreshToken = "refresh_token" Password = "password" Expiry = 3600 )
View Source
const (
ErrorTypeErrorValidation string = "validator.ValidationErrors"
)
const list
Variables ¶
View Source
var (
ErrorInternalError = errors.New("whoops something went wrong")
)
var list
View Source
var ValidationObject = []ExtraValidation{
{Tag: "required", Message: "%s is required!"},
{Tag: "max", Message: "%s cannot be more than %s!"},
{Tag: "min", Message: "%s must be minimum %s!"},
{Tag: "email", Message: "Invalid email format!"},
{Tag: "len", Message: "%s must be %s characters long!"},
}
ValidationObject initialize default Validation object
Functions ¶
func AccessToken ¶
func AccessToken(store *oauth2.Store) gin.HandlerFunc
Return Access Token for valid client and user credential
func CORS ¶
func CORS() gin.HandlerFunc
func Errors ¶
func Errors() gin.HandlerFunc
Errors method collects all errors and submits them to Rollbar
func MakeExtraValidation ¶
func MakeExtraValidation(v []ExtraValidation)
MakeExtraValidation method is for registering new validator
func OauthMiddleware ¶
func OauthMiddleware(store *oauth2.Store) gin.HandlerFunc
Check If access token is valid and have proper scope
func ValidationErrorToText ¶
func ValidationErrorToText(e validator.FieldError) string
ValidationErrorToText method changes FieldError to string
Types ¶
type AccessTokenPayload ¶
type ExtraValidation ¶
ExtraValidation model
type PasswordCredential ¶
type PasswordCredential struct { ClientID string `json:"client_id" binding:"required"` ClientSecret string `json:"client_secret" binding:"required"` Scope string `json:"scope,omitempty" binding:"required"` Username string `json:"username" binding:"required"` Password string `json:"Password" binding:"required"` }
func (PasswordCredential) GetScope ¶
func (pc PasswordCredential) GetScope() string
type RefreshTokenCredential ¶
type RefreshTokenCredential struct { ClientID string `json:"client_id" binding:"required"` ClientSecret string `json:"client_secret" binding:"required"` RefreshToken string `json:"refresh_token" binding:"required"` Scope string `json:"scope,omitempty"` }
func (RefreshTokenCredential) GetScope ¶
func (rtc RefreshTokenCredential) GetScope() string
Click to show internal directories.
Click to hide internal directories.