github.com/jxgolibs/go-oauth2-server@v1.0.1/oauth/service_interface.go (about)

     1  package oauth
     2  
     3  import (
     4  	"github.com/RichardKnop/go-oauth2-server/config"
     5  	"github.com/RichardKnop/go-oauth2-server/models"
     6  	"github.com/RichardKnop/go-oauth2-server/session"
     7  	"github.com/RichardKnop/go-oauth2-server/util/routes"
     8  	"github.com/gorilla/mux"
     9  	"github.com/jinzhu/gorm"
    10  )
    11  
    12  // ServiceInterface defines exported methods
    13  type ServiceInterface interface {
    14  	// Exported methods
    15  	GetConfig() *config.Config
    16  	RestrictToRoles(allowedRoles ...string)
    17  	IsRoleAllowed(role string) bool
    18  	FindRoleByID(id string) (*models.OauthRole, error)
    19  	GetRoutes() []routes.Route
    20  	RegisterRoutes(router *mux.Router, prefix string)
    21  	ClientExists(clientID string) bool
    22  	FindClientByClientID(clientID string) (*models.OauthClient, error)
    23  	CreateClient(clientID, secret, redirectURI string) (*models.OauthClient, error)
    24  	CreateClientTx(tx *gorm.DB, clientID, secret, redirectURI string) (*models.OauthClient, error)
    25  	AuthClient(clientID, secret string) (*models.OauthClient, error)
    26  	UserExists(username string) bool
    27  	FindUserByUsername(username string) (*models.OauthUser, error)
    28  	CreateUser(roleID, username, password string) (*models.OauthUser, error)
    29  	CreateUserTx(tx *gorm.DB, roleID, username, password string) (*models.OauthUser, error)
    30  	SetPassword(user *models.OauthUser, password string) error
    31  	SetPasswordTx(tx *gorm.DB, user *models.OauthUser, password string) error
    32  	UpdateUsername(user *models.OauthUser, username string) error
    33  	UpdateUsernameTx(db *gorm.DB, user *models.OauthUser, username string) error
    34  	AuthUser(username, thePassword string) (*models.OauthUser, error)
    35  	GetScope(requestedScope string) (string, error)
    36  	GetDefaultScope() string
    37  	ScopeExists(requestedScope string) bool
    38  	Login(client *models.OauthClient, user *models.OauthUser, scope string) (*models.OauthAccessToken, *models.OauthRefreshToken, error)
    39  	GrantAuthorizationCode(client *models.OauthClient, user *models.OauthUser, expiresIn int, redirectURI, scope string) (*models.OauthAuthorizationCode, error)
    40  	GrantAccessToken(client *models.OauthClient, user *models.OauthUser, expiresIn int, scope string) (*models.OauthAccessToken, error)
    41  	GetOrCreateRefreshToken(client *models.OauthClient, user *models.OauthUser, expiresIn int, scope string) (*models.OauthRefreshToken, error)
    42  	GetValidRefreshToken(token string, client *models.OauthClient) (*models.OauthRefreshToken, error)
    43  	Authenticate(token string) (*models.OauthAccessToken, error)
    44  	NewIntrospectResponseFromAccessToken(accessToken *models.OauthAccessToken) (*IntrospectResponse, error)
    45  	NewIntrospectResponseFromRefreshToken(refreshToken *models.OauthRefreshToken) (*IntrospectResponse, error)
    46  	ClearUserTokens(userSession *session.UserSession)
    47  	Close()
    48  }