manage.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package oauth2
  2. import (
  3. "net/http"
  4. "time"
  5. )
  6. // TokenGenerateRequest provide to generate the token request parameters
  7. type TokenGenerateRequest struct {
  8. ClientID string
  9. ClientSecret string
  10. UserID string
  11. Domain string
  12. RedirectURI string
  13. Scope string
  14. Code string
  15. Refresh string
  16. AccessTokenExp time.Duration
  17. Request *http.Request
  18. }
  19. // Manager authorization management interface
  20. type Manager interface {
  21. // get the client information
  22. GetClient(clientID string) (cli ClientInfo, err error)
  23. // generate the authorization token(code)
  24. GenerateAuthToken(rt ResponseType, tgr *TokenGenerateRequest) (authToken TokenInfo, err error)
  25. // generate the access token
  26. GenerateAccessToken(rt GrantType, tgr *TokenGenerateRequest) (accessToken TokenInfo, err error)
  27. // refreshing an access token
  28. RefreshAccessToken(tgr *TokenGenerateRequest) (accessToken TokenInfo, err error)
  29. // use the access token to delete the token information
  30. RemoveAccessToken(access string) (err error)
  31. // use the refresh token to delete the token information
  32. RemoveRefreshToken(refresh string) (err error)
  33. // according to the access token for corresponding token information
  34. LoadAccessToken(access string) (ti TokenInfo, err error)
  35. // according to the refresh token for corresponding token information
  36. LoadRefreshToken(refresh string) (ti TokenInfo, err error)
  37. }