authorizeConv ensures principal owns convID (admins bypass). Returns a gRPC status error suitable to return directly.
(ctx context.Context, convID, principal string)
| 49 | // authorizeConv ensures principal owns convID (admins bypass). Returns a |
| 50 | // gRPC status error suitable to return directly. |
| 51 | func (h *Handler) authorizeConv(ctx context.Context, convID, principal string) error { |
| 52 | owner, err := h.hub.OwnerOf(ctx, convID) |
| 53 | if err != nil { |
| 54 | return status.Errorf(codes.NotFound, "%s", i18n.T("server.hub.conv_not_found")) |
| 55 | } |
| 56 | if owner == principal { |
| 57 | return nil |
| 58 | } |
| 59 | if u := UserFromContext(ctx); u != nil && u.HasRole(RoleAdmin) { |
| 60 | return nil |
| 61 | } |
| 62 | return status.Errorf(codes.PermissionDenied, "%s", i18n.T("server.hub.conv_forbidden")) |
| 63 | } |
| 64 | |
| 65 | func (h *Handler) hubReady() error { |
| 66 | if h.hub == nil { |
no test coverage detected