-
Notifications
You must be signed in to change notification settings - Fork 1
/
router.go
35 lines (30 loc) · 975 Bytes
/
router.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
package service
import (
"github.com/go-chi/chi"
"github.com/rarimo/auth-svc/internal/jwt"
"github.com/rarimo/auth-svc/internal/service/handlers"
"github.com/rarimo/auth-svc/internal/service/middleware"
"gitlab.com/distributed_lab/ape"
)
func (s *service) router() chi.Router {
r := chi.NewRouter()
r.Use(
ape.RecoverMiddleware(s.log),
ape.LoganMiddleware(s.log),
ape.CtxMiddleware(
handlers.CtxLog(s.log),
handlers.CtxJWT(s.jwt),
handlers.CtxVerifier(s.verifier),
handlers.CtxCookies(s.cookies),
),
)
r.Route("/integrations/auth-svc", func(r chi.Router) {
r.Route("/v1", func(r chi.Router) {
r.Post("/authorize", handlers.Authorize)
r.Get("/authorize/{did}/challenge", handlers.RequestChallenge)
r.With(middleware.AuthMiddleware(s.jwt, s.log, jwt.AccessTokenType)).Get("/validate", handlers.Validate)
r.With(middleware.AuthMiddleware(s.jwt, s.log, jwt.RefreshTokenType)).Get("/refresh", handlers.Refresh)
})
})
return r
}