github.com/resonatecoop/id@v1.1.0-43/oauth/service_interface.go (about)

     1  package oauth
     2  
     3  import (
     4  	"github.com/gorilla/mux"
     5  	"github.com/resonatecoop/id/config"
     6  	"github.com/resonatecoop/id/session"
     7  	"github.com/resonatecoop/id/util/routes"
     8  	"github.com/resonatecoop/user-api/model"
     9  	"github.com/uptrace/bun"
    10  )
    11  
    12  // ServiceInterface defines exported methods
    13  type ServiceInterface interface {
    14  	// Exported methods
    15  	GetConfig() *config.Config
    16  	RestrictToRoles(allowedRoles ...int32)
    17  	IsRoleAllowed(role int32) bool
    18  	FindRoleByID(id int32) (*model.AccessRole, error)
    19  	GetRoutes() []routes.Route
    20  	RegisterRoutes(router *mux.Router, prefix string)
    21  	ClientExists(clientID string) bool
    22  	FindClientByClientID(clientID string) (*model.Client, error)
    23  	FindClientByApplicationURL(applicationURL string) (*model.Client, error)
    24  	CreateClient(clientID, secret, redirectURI, applicationName, applicationHostname, applicationURL string) (*model.Client, error)
    25  	CreateClientTx(tx *bun.DB, clientID, secret, redirectURI, applicationName, applicationHostname, applicationURL string) (*model.Client, error)
    26  	AuthClient(clientID, secret string) (*model.Client, error)
    27  	GetValidEmailToken(token string) (*model.EmailToken, *model.User, error)
    28  	ClearExpiredEmailTokens() error
    29  	DeleteEmailToken(*model.EmailToken, bool) error
    30  	SendEmailToken(email *model.Email, emailTokenLink string) (*model.EmailToken, error)
    31  	SendEmailTokenTx(db *bun.DB, email *model.Email, emailTokenLink string) (*model.EmailToken, error)
    32  	UserExists(username string) bool
    33  	FindUserByUsername(username string) (*model.User, error)
    34  	FindUserByEmail(email string) (*model.User, error)
    35  	DeleteUser(user *model.User, password string) error
    36  	DeleteUserTx(tx *bun.DB, user *model.User, password string) error
    37  	ConfirmUserEmail(email string) error
    38  	SetPassword(user *model.User, password string) error
    39  	SetPasswordTx(tx *bun.DB, user *model.User, password string) error
    40  	UpdateUsername(user *model.User, username, password string) error
    41  	UpdateUsernameTx(db *bun.DB, user *model.User, username, password string) error
    42  	UpdateUser(user *model.User, fullName, firstName, lastName, country string, newsletter bool) error
    43  	SetUserCountry(user *model.User, country string) error
    44  	SetUserCountryTx(db *bun.DB, user *model.User, country string) error
    45  	AuthUser(username, thePassword string) (*model.User, error)
    46  	GetScope(requestedScope string) (string, error)
    47  	GetDefaultScope() string
    48  	ScopeExists(requestedScope string) bool
    49  	Login(client *model.Client, user *model.User, scope string) (*model.AccessToken, *model.RefreshToken, error)
    50  	GrantAuthorizationCode(client *model.Client, user *model.User, expiresIn int, redirectURI, scope string) (*model.AuthorizationCode, error)
    51  	GrantAccessToken(client *model.Client, user *model.User, expiresIn int, scope string) (*model.AccessToken, error)
    52  	GetOrCreateRefreshToken(client *model.Client, user *model.User, expiresIn int, scope string) (*model.RefreshToken, error)
    53  	GetValidRefreshToken(token string, client *model.Client) (*model.RefreshToken, error)
    54  	Authenticate(token string) (*model.AccessToken, error)
    55  	NewIntrospectResponseFromAccessToken(accessToken *model.AccessToken) (*IntrospectResponse, error)
    56  	NewIntrospectResponseFromRefreshToken(refreshToken *model.RefreshToken) (*IntrospectResponse, error)
    57  	ClearUserTokens(userSession *session.UserSession)
    58  	Close()
    59  }