# rpc错误：代码=权限被拒绝 描述=用户'alice'没有访问资源'admin-panel'的权限

- **ID:** `go/grpc-permission-denied-rbac`
- **领域:** go
- **类别:** auth_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

认证的用户缺少请求操作所需的角色或权限。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## 解决方案

1. **Grant the necessary permissions to the user in the authorization system.** (90% 成功率)
   ```
   Update role-based access control (RBAC) policies to include the user for the admin-panel resource.
   ```
2. **Use a service account with appropriate permissions.** (85% 成功率)
   ```
   conn, err := grpc.Dial("localhost:8080", grpc.WithInsecure(), grpc.WithPerRPCCredentials(&serviceAccountCreds{}))
   ```

## 无效尝试

- **Retry the request with the same credentials.** — The user's permissions haven't changed; retrying will still fail. (100% 失败率)
- **Use a different user's token without proper authorization.** — Using another user's token may be a security violation and may still lack permissions. (80% 失败率)
