MSP-1069 add repo admin auth
This commit is contained in:
1 parent
57dff99bb5
commit
9163d0749d
1 file changed
+33
@@ -0,0 +1,33 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"isp-gate-service/domain"
|
||||
|
||||
"github.com/integration-system/isp-kit/grpc/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
adminAuthenticate = "admin/secure/authenticate"
|
||||
)
|
||||
|
||||
type Admin struct {
|
||||
cli *client.Client
|
||||
}
|
||||
|
||||
func NewAdmin(cli *client.Client) Admin {
|
||||
return Admin{cli: cli}
|
||||
}
|
||||
|
||||
func (r Admin) Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error) {
|
||||
resp := domain.AdminAuthenticateResponse{}
|
||||
err := r.cli.Invoke(adminAuthenticate).
|
||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
||||
ReadJsonResponse(&resp).
|
||||
Do(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "grpc client invoke %s", adminAuthenticate)
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
Reference in new issue
Block a user