feat: enhance media access and security for exercises
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 23s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 25s
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 23s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 25s
- Updated PostgreSQL binding in docker-compose to restrict access to localhost only. - Implemented a new API endpoint for secure media file delivery, requiring authentication via token. - Enhanced governance checks for exercise media access, ensuring only authorized users can retrieve files. - Updated frontend components to utilize the new media file access method, improving user experience while maintaining security. - Documented changes in production readiness audit and access layer endpoint audit for clarity on security enhancements.
This commit is contained in:
1 parent
c2d9eac151
commit
b752883392
13 files changed
+235
-42
No files matched your search
@@ -4,15 +4,7 @@
|
||||
import React from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { sanitizeTrainerHtml } from '../utils/htmlUtils'
|
||||
|
||||
const API_BASE = (import.meta.env.VITE_API_URL || '').replace(/\/$/, '')
|
||||
|
||||
function resolveMediaUrl(filePath) {
|
||||
if (!filePath) return null
|
||||
if (filePath.startsWith('http://') || filePath.startsWith('https://')) return filePath
|
||||
const p = filePath.startsWith('/') ? filePath : `/${filePath}`
|
||||
return `${API_BASE}${p}`
|
||||
}
|
||||
import { resolveExerciseMediaFileUrl } from '../utils/exerciseMediaUrl'
|
||||
|
||||
function HtmlBlock({ html, className = '' }) {
|
||||
if (!html || !String(html).trim()) return null
|
||||
@@ -22,7 +14,7 @@ function HtmlBlock({ html, className = '' }) {
|
||||
)
|
||||
}
|
||||
|
||||
function MediaBlock({ media }) {
|
||||
function MediaBlock({ media, exerciseId }) {
|
||||
if (media.embed_url) {
|
||||
return (
|
||||
<div style={{ marginTop: '0.5rem' }}>
|
||||
@@ -37,7 +29,7 @@ function MediaBlock({ media }) {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const src = resolveMediaUrl(media.file_path)
|
||||
const src = resolveExerciseMediaFileUrl(exerciseId, media)
|
||||
if (!src) return null
|
||||
if (media.media_type === 'image' || (media.mime_type && media.mime_type.startsWith('image/'))) {
|
||||
return (
|
||||
@@ -178,7 +170,7 @@ export default function ExerciseFullContent({ exercise, loading, error, exercise
|
||||
<div key={m.id} style={{ marginBottom: '12px' }}>
|
||||
<strong style={{ fontSize: '0.9rem' }}>{m.title || m.original_filename || m.media_type}</strong>
|
||||
{m.description && <p style={{ color: 'var(--text2)', fontSize: '0.82rem', marginTop: '4px' }}>{m.description}</p>}
|
||||
<MediaBlock media={m} />
|
||||
<MediaBlock media={m} exerciseId={exercise.id ?? exerciseId} />
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user