mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-07-30 23:38:02 -04:00
- Introduced the Endurain integration, allowing users to connect their self-hosted Endurain instance for activity browsing and GPX import. - Added `EndurainIntegration` model, serializer, and viewset to manage user connections and activities. - Implemented MFA support for Endurain login, including token handling and validation. - Enhanced activity handling in `ActivityViewSet` to prioritize user-provided elevation data over GPX-derived values. - Updated environment configuration and documentation to include Endurain integration details. - Added tests for Endurain services and integration functionality to ensure reliability and correctness. - Improved throttling for Endurain authentication to enhance security and performance.
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
from django.conf import settings
|
|
from rest_framework.throttling import UserRateThrottle
|
|
|
|
|
|
class ConditionalUserRateThrottle(UserRateThrottle):
|
|
def get_rate(self):
|
|
if not getattr(settings, "ENABLE_RATE_LIMITS", False):
|
|
return None
|
|
return super().get_rate()
|
|
|
|
|
|
class ImageProxyThrottle(ConditionalUserRateThrottle):
|
|
scope = "image_proxy"
|
|
|
|
|
|
class ImageImportThrottle(ConditionalUserRateThrottle):
|
|
scope = "image_import"
|
|
|
|
|
|
class ExternalGeocodeThrottle(ConditionalUserRateThrottle):
|
|
scope = "external_geocode"
|
|
|
|
|
|
class ExternalRecommendationsThrottle(ConditionalUserRateThrottle):
|
|
scope = "external_recommendations"
|
|
|
|
|
|
class ExternalWikipediaThrottle(ConditionalUserRateThrottle):
|
|
scope = "external_wikipedia"
|
|
|
|
|
|
class ExternalSunriseSunsetThrottle(ConditionalUserRateThrottle):
|
|
scope = "external_sunrise_sunset"
|
|
|
|
|
|
class EndurainAuthThrottle(UserRateThrottle):
|
|
"""
|
|
Always-on throttle for Endurain connect/MFA credential proxying.
|
|
Independent of ENABLE_RATE_LIMITS so auth guessing cannot use AdventureLog as a relay.
|
|
"""
|
|
|
|
scope = "endurain_auth"
|
|
|
|
def get_rate(self):
|
|
rates = getattr(settings, "RATE_LIMIT_RATES", {}) or {}
|
|
return rates.get(self.scope, "10/minute")
|