rs_server_catalog/authentication_catalog.md
Contains all functions used to manage the authentication in the catalog.
check_user_authorization(request_ids)
Checks that current user/owner is allowed to do operations on catalog objects.
The request middleware may not know the owner until the body is inspected. This helper resolves a missing owner first, then enforces write access in cluster mode.
Raises:
| Type | Description |
|---|---|
HTTPException
|
When the user doesn't have the expected authorizations |
Source code in docs/rs-server/services/catalog/rs_server_catalog/authentication_catalog.py
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 | |
get_all_accessible_collections(collections, auth_roles, user_login)
Return the list of all collections accessible by the user calling it.
In cluster mode, the landing page and /collections response must hide
collections the caller cannot read. Local mode is handled by
get_authorisation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collections
|
dict
|
List of all collections. |
required |
auth_roles
|
list
|
List of roles of the api-key. |
required |
user_login
|
str
|
The api-key owner. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
list[dict]
|
The list of all collections accessible by the user. |
Source code in docs/rs-server/services/catalog/rs_server_catalog/authentication_catalog.py
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 | |
get_authorisation(requested_col_ids, auth_roles, requested_action, requested_owner_id, user_login, owner_prefix=False, raise_if_unauthorized=False)
Check if the user is authorized to access collections.
Authorization roles follow the pattern
rs_catalog_<owner_id>:<collection_id>_<read|write|download>. Wildcards are
accepted for owner or collection. In local mode, authorization is bypassed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requested_col_ids
|
list
|
IDs of the requested collections. |
required |
auth_roles
|
list
|
The list of authorisations for the user_login. |
required |
requested_action
|
str
|
Requested action (read, write or download) on the collections. |
required |
requested_owner_id
|
str
|
The name of the owner of the collection {collection_id}. |
required |
user_login
|
str
|
The owner of the apikey or oauth2 cookie linked to the request. |
required |
owner_prefix
|
bool
|
True if the collection IDs are prefixed by their collection |
False
|
raise_if_unauthorized
|
bool
|
If True, raise an HTTPException if the user is unauthorized |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the user is authorized, else False |
Source code in docs/rs-server/services/catalog/rs_server_catalog/authentication_catalog.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |