|
| 1 | +--- |
| 2 | +sidebar_position: 4 |
| 3 | +title: Authorization |
| 4 | +--- |
| 5 | + |
| 6 | +# Authorization |
| 7 | + |
| 8 | +The RO-Crate API uses an `access` property on each entity which signals to the |
| 9 | +consumer that level of access the current user has to metadata and content. |
| 10 | +This is designed to allow consumers of the API like Oni UI to communicate what |
| 11 | +is accessible and redirect to enrollment URLs when access is restricted. |
| 12 | + |
| 13 | +## Access Property Structure |
| 14 | + |
| 15 | +Each entity in the API includes an `access` object with the following |
| 16 | +structure: |
| 17 | + |
| 18 | +```json |
| 19 | +{ |
| 20 | + "access": { |
| 21 | + "metadata": true, |
| 22 | + "content": false, |
| 23 | + "metadataAuthorizationUrl": "https://example.com/apply?item=123", |
| 24 | + "contentAuthorizationUrl": "https://example.com/apply?item=123" |
| 25 | + } |
| 26 | +} |
| 27 | +``` |
| 28 | + |
| 29 | +### Required Fields |
| 30 | + |
| 31 | +- **`metadata`** (boolean): Whether the current user has access to view the |
| 32 | +entity's metadata |
| 33 | +- **`content`** (boolean): Whether the current user has access to download or |
| 34 | +view the entity's content files |
| 35 | + |
| 36 | +### Optional Fields |
| 37 | + |
| 38 | +- **`metadataAuthorizationUrl`** (string): URL where users can request access |
| 39 | +to metadata when `metadata` is `false` |
| 40 | +- **`contentAuthorizationUrl`** (string): URL where users can request access to |
| 41 | +content when `content` is `false` |
| 42 | + |
| 43 | +## Authorization Rules |
| 44 | + |
| 45 | +### Validation Requirements |
| 46 | + |
| 47 | +When implementing the API, the following validation rules MUST be enforced: |
| 48 | + |
| 49 | +- If `metadata` is `false`, then `metadataAuthorizationUrl` MUST be provided |
| 50 | +- If `content` is `false`, then `contentAuthorizationUrl` MUST be provided |
| 51 | +- Entities that violate these rules should not be surfaced in API responses |
| 52 | + |
| 53 | +### Implementation Flexibility |
| 54 | + |
| 55 | +The authorization system provides maximum flexibility to implementors: |
| 56 | + |
| 57 | +- **Enrollment URL format**: Completely open to implementor design |
| 58 | +- **Authorization flow**: The process after visiting an enrollment URL is up to |
| 59 | +the implementor |
| 60 | +- **Access determination**: How the API determines user access is |
| 61 | +implementation-specific |
| 62 | + |
| 63 | +## Access Scenarios and Examples |
| 64 | + |
| 65 | +### 1. Full Access |
| 66 | + |
| 67 | +Both metadata and content are accessible to the current user: |
| 68 | + |
| 69 | +```json |
| 70 | +{ |
| 71 | + "id": "https://catalog.example.com/repository/PUBLIC/001", |
| 72 | + "name": "Public Research Data", |
| 73 | + "access": { |
| 74 | + "metadata": true, |
| 75 | + "content": true |
| 76 | + } |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +### 2. Metadata Only Access |
| 81 | + |
| 82 | +User can view metadata but must request access for content: |
| 83 | + |
| 84 | +```json |
| 85 | +{ |
| 86 | + "id": "https://catalog.example.com/repository/RESTRICTED/001", |
| 87 | + "name": "Sensitive Audio Recordings", |
| 88 | + "access": { |
| 89 | + "metadata": true, |
| 90 | + "content": false, |
| 91 | + "contentAuthorizationUrl": "https://ethics.example.com/apply?collection=RESTRICTED-001" |
| 92 | + } |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +### 3. No Access |
| 97 | + |
| 98 | +User must request access for both metadata and content: |
| 99 | + |
| 100 | +```json |
| 101 | +{ |
| 102 | + "id": "https://catalog.example.com/repository/PRIVATE/001", |
| 103 | + "name": "Confidential Collection", |
| 104 | + "access": { |
| 105 | + "metadata": false, |
| 106 | + "content": false, |
| 107 | + "metadataAuthorizationUrl": "https://portal.example.com/metadata-access?id=PRIVATE-001", |
| 108 | + "contentAuthorizationUrl": "https://portal.example.com/content-access?id=PRIVATE-001" |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +``` |
| 113 | + |
| 114 | +### 4. Content Only Access |
| 115 | + |
| 116 | +User can access content but not detailed metadata (rare scenario): |
| 117 | + |
| 118 | +```json |
| 119 | +{ |
| 120 | + "id": "https://catalog.example.com/repository/CLASSIFIED/001", |
| 121 | + "name": "Research Materials", |
| 122 | + "access": { |
| 123 | + "metadata": false, |
| 124 | + "content": true, |
| 125 | + "metadataAuthorizationUrl": "https://clearance.example.com/request?item=CLASSIFIED-001" |
| 126 | + } |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +### 5. Invalid Configurations |
| 131 | + |
| 132 | +These examples show invalid configurations that should result in errors: |
| 133 | + |
| 134 | +```json |
| 135 | +// ERROR: content is false but no contentAuthorizationUrl provided |
| 136 | +{ |
| 137 | + "access": { |
| 138 | + "metadata": true, |
| 139 | + "content": false |
| 140 | + // Missing contentAuthorizationUrl |
| 141 | + } |
| 142 | +} |
| 143 | + |
| 144 | +// ERROR: metadata is false but no metadataAuthorizationUrl provided |
| 145 | +{ |
| 146 | + "access": { |
| 147 | + "metadata": false, // Missing metadataAuthorizationUrl |
| 148 | + "content": true |
| 149 | + } |
| 150 | +} |
| 151 | +``` |
| 152 | + |
| 153 | +## Client Implementation Guidelines |
| 154 | + |
| 155 | +### Checking Access |
| 156 | + |
| 157 | +Before attempting to access entity metadata or content, clients should check |
| 158 | +the access property: |
| 159 | + |
| 160 | +```javascript |
| 161 | +function canAccessMetadata(entity) { |
| 162 | + return entity.access.metadata === true; |
| 163 | +} |
| 164 | + |
| 165 | +function canAccessContent(entity) { |
| 166 | + return entity.access.content === true; |
| 167 | +} |
| 168 | + |
| 169 | +function getEnrollmentUrl(entity, type) { |
| 170 | + if (type === 'metadata' && !entity.access.metadata) { |
| 171 | + return entity.access.metadataAuthorizationUrl; |
| 172 | + } |
| 173 | + |
| 174 | + if (type === 'content' && !entity.access.content) { |
| 175 | + return entity.access.contentAuthorizationUrl; |
| 176 | + } |
| 177 | + return null; |
| 178 | +} |
| 179 | +``` |
| 180 | + |
| 181 | +### Handling Restricted Access |
| 182 | + |
| 183 | +When access is denied, present the enrollment URL to users: |
| 184 | + |
| 185 | +```javascript |
| 186 | +if (!canAccessContent(entity)) { |
| 187 | + const enrollmentUrl = getEnrollmentUrl(entity, 'content'); |
| 188 | + // Display message: "Access restricted. Apply for access at: {enrollmentUrl}" |
| 189 | +} |
| 190 | +``` |
| 191 | + |
| 192 | +## Use Cases |
| 193 | + |
| 194 | +### Public Archives |
| 195 | + |
| 196 | +Most content publicly accessible with some restricted materials: |
| 197 | + |
| 198 | +- `metadata: true, content: true` - Open research data |
| 199 | +- `metadata: true, content: false` - Culturally sensitive materials requiring |
| 200 | +approval |
| 201 | + |
| 202 | +### Institutional Repositories |
| 203 | + |
| 204 | +Metadata discoverable but content restricted to authenticated users: |
| 205 | + |
| 206 | +- `metadata: true, content: false` - Internal research requiring institutional login |
| 207 | + |
| 208 | +### Sensitive Collections |
| 209 | + |
| 210 | +Both metadata and content require special authorization: |
| 211 | + |
| 212 | +- `metadata: false, content: false` - Classified or highly sensitive materials |
| 213 | + |
| 214 | +## Implementation Notes |
| 215 | + |
| 216 | +- Authorization URLs can point to any system: web forms, OAuth providers, |
| 217 | +institutional portals, etc. |
| 218 | +- The API does not prescribe the enrollment process - this is entirely up to |
| 219 | +the implementor |
| 220 | +- Access permissions may be user-specific, time-based, or dependent on other |
| 221 | +factors |
| 222 | +- Consider caching authorization decisions to improve performance |
| 223 | +- Ensure authorization URLs are accessible and provide clear instructions to |
| 224 | +users |
0 commit comments