Documentation ¶
Index ¶
- Variables
- func Authorize(token string) bool
- func GetAccessTokenFromRefreshToken(refreshToken string) (accessToken string, err error)
- func GetRefreshTokenFromAccessToken(accessToken string) (refreshToken string, err error)
- func Refresh(refreshToken string) (accessToken string, err error)
- func RefreshAndGetClient(refreshToken string, object interface{}) (string, error)
- func Register(id interface{}) (refreshToken, accessToken string, err error)
- func SetAccessCollection(collection *mgo.Collection)
- func SetClientCollection(collection *mgo.Collection)
- func SetRemainingTime(accessToken string, date time.Time) (err error)
- func SetTokenExpiration(expiration time.Duration)
- type Client
Constants ¶
This section is empty.
Variables ¶
var (
IDFieldName = "_id"
)
Functions ¶
func GetAccessTokenFromRefreshToken ¶
GetAccessTokenFromRefreshToken returns the accessToken of the user associated by this refreshToken.
func GetRefreshTokenFromAccessToken ¶
GetRefreshTokenFromAccessToken returns the refreshToken of the user associated by this accessToken.
func RefreshAndGetClient ¶
RefreshAndGetClient refreshes the user and returns it.
func Register ¶
Register a new client. The client must exists in the collection given via the function SetClientCollection. The ID parameter is the ID of the client that needs to be registered.
func SetAccessCollection ¶
func SetAccessCollection(collection *mgo.Collection)
SetAccessCollection sets the collection used to store the AccessData. By default, the AccessToken expiration is set to 10 minutes, to changes it, call SetTokenExpiration before this function.
func SetClientCollection ¶
func SetClientCollection(collection *mgo.Collection)
SetClientCollection sets the collection used to query the clientID (clientID must be the "_id" of the collection).
func SetRemainingTime ¶
SetRemainingTime set the new date at which the token will expires.
func SetTokenExpiration ¶
SetTokenExpiration set a new token duration (by default it is set to 10 minutes). This function must be called before SetClientCollection to have any effect.
Types ¶
type Client ¶
type Client struct { RefreshToken string `json:"refreshToken,omitempty" bson:"refreshToken"` AccessToken string `json:"accessToken,omitempty" bson:"-"` }
Client is a simple struct with a RefreshToken field. This struct has to be embedded by the struct populating the Client Collection set by the user.