blob: a881b41be05579631e4315efa321d1c258004d4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package rpc
import (
context "context"
"net/http"
"github.com/xlgmokha/x/pkg/x"
"gitlab.com/mokhax/spike/pkg/authz"
)
type AbilityHandler struct {
authorizer authz.Authorizer
UnimplementedAbilityServer
}
func (h *AbilityHandler) Allowed(ctx context.Context, req *AllowRequest) (*AllowReply, error) {
// TODO:: Replace http.Request with authz.Request
request := x.Must(http.NewRequestWithContext(ctx, req.Permission, req.Resource, nil))
return &AllowReply{Result: h.authorizer.Authorize(request)}, nil
}
|