Permissions
permissions
Classes
RebacConfiguredView
Bases: Protocol
Protocol defining the expected interface for an ReBAC-protected view.
IsRebacAuthorized
Bases: BasePermission
Evaluates ReBAC authorization rules strictly based on the view's RebacViewConfig.
Functions
has_permission
Validates identity context and handles creation (POST) parent verification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming HTTP request. |
required |
view
|
APIView | RebacConfiguredView
|
The DRF view instance. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the request is allowed to proceed, False otherwise. |
Source code in src/rebac/permissions.py
has_object_permission
Validates fine-grained object access based on HTTP method or ViewSet action.
If the corresponding relation in the view's RebacViewConfig is explicitly set to None, this check is bypassed and access is automatically granted, adhering to the documented opt-out contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming HTTP request. |
required |
view
|
APIView | RebacConfiguredView
|
The DRF view instance. |
required |
obj
|
object
|
The database object being accessed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the user holds the required relation on the object (or if the check is explicitly disabled), False otherwise. |
Source code in src/rebac/permissions.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |