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