-
Notifications
You must be signed in to change notification settings - Fork 2
/
service.go
43 lines (34 loc) · 883 Bytes
/
service.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
package server
import (
"net/http"
"github.com/dpb587/ssoca/auth"
svc "github.com/dpb587/ssoca/auth/authn/google"
svcconfig "github.com/dpb587/ssoca/auth/authn/google/config"
oauth2support "github.com/dpb587/ssoca/auth/authn/support/oauth2"
"github.com/dpb587/ssoca/server/service/req"
)
type Service struct {
svc.Service
name string
config svcconfig.Config
oauth oauth2support.Backend
}
func NewService(name string, config svcconfig.Config, oauth oauth2support.Backend) Service {
return Service{
name: name,
config: config,
oauth: oauth,
}
}
func (s Service) Name() string {
return s.name
}
func (s Service) Metadata() interface{} {
return nil
}
func (s Service) GetRoutes() []req.RouteHandler {
return s.oauth.GetRoutes(s.OAuthUserProfileLoader)
}
func (s Service) IsAuthorized(_ http.Request, _ *auth.Token) (bool, error) {
return true, nil
}