-
-
Notifications
You must be signed in to change notification settings - Fork 210
API Key, Webkit Fixes, Rate Limit Support & Other Misc. Fixes #1094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
5f5830a
Refactor AdventureLog Bot workflow to improve issue validation handli…
seanmorley15 1dcf99b
feat: add API key management to settings page
seanmorley15 cd85a73
feat: add API Keys documentation and update contributing guidelines
seanmorley15 8c03126
fix: update appVersion to reflect the latest build
seanmorley15 fa3a5e0
fix: update @tailwindcss/typography to version 0.5.19
seanmorley15 6cb32be
fix: update @tailwindcss/typography to version 0.5.19
seanmorley15 65be973
chore: update dependencies in pnpm-lock.yaml
seanmorley15 d93027a
fix: update appVersion to include the latest build identifier
seanmorley15 b15724f
fix: enhance authentication fallback for protected media access
seanmorley15 8fc16d5
feat(auth): add 'mobile-qr' to trailing slash list for URL handling
seanmorley15 b5da5c1
Translated using Weblate (French)
lesensei 34031d3
Translated using Weblate (Korean)
79ecf1d
Translated using Weblate (German)
vorbeiei 4046e4c
Translated using Weblate (Swedish)
bd9ba3f
Added translation using Weblate (Catalan)
mllopart e03c96c
Translated using Weblate (Catalan)
mllopart 6467f14
Docs: Reorder immich API permissions to natural order (#1086)
stephanzwicknagl 9104809
Translated using Weblate (Turkish)
orhunavcu b00a04b
Translated using Weblate (Swedish)
bittin a7aa1ca
Translated using Weblate (German)
vorbeiei e2a7e18
Add ENABLE_RATE_LIMITS configuration for backend rate limiting
seanmorley15 2313e8f
Set tabindex to -1 for dropdown menus to improve accessibility
seanmorley15 770e063
Merge branch 'main' into development
seanmorley15 1983ba9
Refactor settings page: Simplify HTML structure and improve date form…
seanmorley15 3b029ce
Update DEFAULT_SCHEMA_CLASS to use OpenAPI schema in REST framework s…
seanmorley15 bac6139
fix: update error message for key copying and enhance usage instructi…
seanmorley15 3f874ea
Implement feature X to enhance user experience and fix bug Y in module Z
seanmorley15 5c40616
feat: add .dockerignore and update Dockerfile for improved build process
seanmorley15 118f637
fix: add missing svelte-i18n>esbuild override in pnpm-lock and pnpm-w…
seanmorley15 d8000b6
refactor: update frontend CI workflow for improved quality checks and…
seanmorley15 d562556
Refactor code structure for improved readability and maintainability
seanmorley15 4fa6777
fix: add vite>esbuild override in pnpm-lock and pnpm-workspace files
seanmorley15 6fc5b56
refactor: enhance accessibility and semantics of button elements acro…
seanmorley15 4944382
feat: update API key deletion confirmation messages in multiple langu…
seanmorley15 a14b3cd
fix: update djangorestframework version constraint and drf-yasg versi…
seanmorley15 5c659c3
fix: update appVersion to v0.12.0-main-040426 and refactor button ele…
seanmorley15 6af1de8
feat: implement developer unlock feature for mobile login in Avatar c…
seanmorley15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| """ | ||
| Custom DRF authentication backend for AdventureLog API keys. | ||
|
|
||
| Clients may supply their key via either of these headers: | ||
|
|
||
| Authorization: Api-Key al_xxxxxxxxxxxxxxxx... | ||
| X-API-Key: al_xxxxxxxxxxxxxxxx... | ||
|
|
||
| Session-based CSRF enforcement is performed by DRF's built-in | ||
| ``SessionAuthentication`` class only. Requests authenticated via this | ||
| class are never subject to CSRF checks, which is the correct behaviour | ||
| for token-based API access. | ||
| """ | ||
|
|
||
| from rest_framework.authentication import BaseAuthentication | ||
| from rest_framework.exceptions import AuthenticationFailed | ||
|
|
||
|
|
||
| class APIKeyAuthentication(BaseAuthentication): | ||
| """Authenticate a request using an AdventureLog API key.""" | ||
|
|
||
| def authenticate(self, request): | ||
| raw_key = self._extract_key(request) | ||
| if raw_key is None: | ||
| # Signal to DRF that this scheme was not attempted so other | ||
| # authenticators can still run. | ||
| return None | ||
|
|
||
| from .models import APIKey | ||
|
|
||
| api_key = APIKey.authenticate(raw_key) | ||
| if api_key is None: | ||
| raise AuthenticationFailed("Invalid or expired API key.") | ||
|
|
||
| return (api_key.user, api_key) | ||
|
|
||
| def authenticate_header(self, request): | ||
| return "Api-Key" | ||
|
|
||
| @staticmethod | ||
| def _extract_key(request) -> str | None: | ||
| # Prefer X-API-Key header for simplicity. | ||
| key = request.META.get("HTTP_X_API_KEY") | ||
| if key: | ||
| return key.strip() | ||
|
|
||
| # Also accept "Authorization: Api-Key <token>" | ||
| auth_header = request.META.get("HTTP_AUTHORIZATION", "") | ||
| if auth_header.lower().startswith("api-key "): | ||
| return auth_header[8:].strip() | ||
|
|
||
| return None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Generated by Django 5.2.11 on 2026-03-16 18:54 | ||
|
|
||
| import django.db.models.deletion | ||
| import uuid | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('users', '0006_customuser_default_currency'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='APIKey', | ||
| fields=[ | ||
| ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
| ('name', models.CharField(max_length=100)), | ||
| ('key_prefix', models.CharField(editable=False, max_length=12)), | ||
| ('key_hash', models.CharField(editable=False, max_length=64, unique=True)), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('last_used_at', models.DateTimeField(blank=True, null=True)), | ||
| ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='api_keys', to=settings.AUTH_USER_MODEL)), | ||
| ], | ||
| options={ | ||
| 'ordering': ['-created_at'], | ||
| }, | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This middleware disables CSRF enforcement purely based on the presence of
X-API-Key(and similarly forAuthorization: Api-Key ...). If a request also carries a valid session cookie, CSRF could be bypassed for session-authenticated Django views. Consider only skipping CSRF when no session cookie is present, or validating the API key before setting_dont_enforce_csrf_checks.