27 lines
547 B
Go
27 lines
547 B
Go
package palauthiam
|
|
|
|
import "context"
|
|
|
|
type CheckPermissionRequest struct {
|
|
UserID string
|
|
Permission IAMPermission
|
|
}
|
|
|
|
type CheckPermissionResponse struct {
|
|
Allowed bool `json:"allowed"`
|
|
}
|
|
|
|
func (c *PalAuthIAMClient) CheckPermission(ctx context.Context, request *CheckPermissionRequest) (bool, error) {
|
|
resp := CheckPermissionResponse{}
|
|
err := c.getRequest(ctx, "/check", map[string]string{
|
|
"userId": request.UserID,
|
|
"permission": string(request.Permission),
|
|
}, &resp)
|
|
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return resp.Allowed, nil
|
|
}
|