@@ -13,9 +13,9 @@ import (
13
13
"github.com/android-sms-gateway/server/internal/sms-gateway/modules/auth"
14
14
"github.com/android-sms-gateway/server/internal/sms-gateway/modules/devices"
15
15
"github.com/android-sms-gateway/server/internal/sms-gateway/modules/messages"
16
- "github.com/capcom6/go-infra-fx/http/apikey"
17
16
"github.com/go-playground/validator/v10"
18
17
"github.com/gofiber/fiber/v2"
18
+ "github.com/gofiber/fiber/v2/middleware/keyauth"
19
19
"github.com/gofiber/fiber/v2/middleware/limiter"
20
20
"github.com/jaevor/go-nanoid"
21
21
"go.uber.org/fx"
@@ -181,12 +181,17 @@ func (h *mobileHandler) patchMessage(device models.Device, c *fiber.Ctx) error {
181
181
func (h * mobileHandler ) Register (router fiber.Router ) {
182
182
router = router .Group ("/mobile/v1" )
183
183
184
- router .Post ("/device" , limiter .New (), apikey .New (apikey.Config {
185
- Next : func (c * fiber.Ctx ) bool { return h .authSvc .IsPublic () },
186
- Authorizer : func (token string ) bool {
187
- return h .authSvc .AuthorizeRegistration (token ) == nil
188
- },
189
- }), h .postDevice )
184
+ router .Post ("/device" ,
185
+ limiter .New (),
186
+ keyauth .New (keyauth.Config {
187
+ Next : func (c * fiber.Ctx ) bool { return h .authSvc .IsPublic () },
188
+ Validator : func (c * fiber.Ctx , token string ) (bool , error ) {
189
+ err := h .authSvc .AuthorizeRegistration (token )
190
+ return err == nil , err
191
+ },
192
+ }),
193
+ h .postDevice ,
194
+ )
190
195
191
196
router .Use (func (c * fiber.Ctx ) (err error ) {
192
197
header := c .Get (fiber .HeaderAuthorization )
0 commit comments