Example #1
0
 def _waffle_switch(switch_name):
     """
     Returns a ``WaffleSwitch`` object in WAFFLE_NAMESPACE
     with the given ``switch_name``.
     """
     WaffleSwitch = import_waffle_switch()  # pylint: disable=invalid-name
     return WaffleSwitch(WAFFLE_NAMESPACE, switch_name)  # pylint: disable=feature-toggle-needs-doc
Example #2
0
from student import STUDENT_WAFFLE_NAMESPACE
from student.models import (
    AccountRecovery, AllowedAuthUser, CourseAccessRole, CourseEnrollment,
    CourseEnrollmentAllowed, DashboardConfiguration,
    LinkedInAddToProfileConfiguration, LoginFailures, PendingNameChange,
    Registration, RegistrationCookieConfiguration, UserAttribute, UserProfile,
    UserTestGroup, BulkUnenrollConfiguration, AccountRecoveryConfiguration)
from student.roles import REGISTERED_ACCESS_ROLES
from xmodule.modulestore.django import modulestore

User = get_user_model()  # pylint:disable=invalid-name

# This switch exists because the CourseEnrollment admin views make DB queries that impact performance.
# In a large enough deployment of Open edX, this is enough to cause a site outage.
# See https://openedx.atlassian.net/browse/OPS-2943
COURSE_ENROLLMENT_ADMIN_SWITCH = WaffleSwitch(STUDENT_WAFFLE_NAMESPACE,
                                              'courseenrollment_admin')


class _Check(object):
    """
    A method decorator that pre-emptively returns false if a feature is disabled.
    Otherwise, it returns the return value of the decorated method.

    To use, add this decorator above a method and pass in a function that returns
    a boolean indicating whether the feature is enabled.

    Example:
    @_Check.is_enabled(FEATURE_TOGGLE.is_enabled)
    """
    @classmethod
    def is_enabled(cls, is_enabled_func):
Example #3
0
"""
Enrollment API helpers and settings
"""
from openedx.core.djangoapps.waffle_utils import (WaffleSwitch,
                                                  WaffleSwitchNamespace)

WAFFLE_SWITCH_NAMESPACE = WaffleSwitchNamespace(
    name='enrollment_api_rate_limit')

USE_RATE_LIMIT_400_FOR_STAFF_FOR_ENROLLMENT_API = WaffleSwitch(
    WAFFLE_SWITCH_NAMESPACE, 'staff_rate_limit_400')
USE_RATE_LIMIT_100_FOR_STAFF_FOR_ENROLLMENT_API = WaffleSwitch(
    WAFFLE_SWITCH_NAMESPACE, 'staff_rate_limit_100')
USE_RATE_LIMIT_40_FOR_ENROLLMENT_API = WaffleSwitch(WAFFLE_SWITCH_NAMESPACE,
                                                    'rate_limit_40')
Example #4
0
"""
Platform support for Programs.

This package is a thin wrapper around interactions with the Programs service,
supporting learner- and author-facing features involving that service
if and only if the service is deployed in the Open edX installation.

To ensure maximum separation of concerns, and a minimum of interdependencies,
this package should be kept small, thin, and stateless.
"""
from openedx.core.djangoapps.waffle_utils import (WaffleSwitch,
                                                  WaffleSwitchNamespace)

PROGRAMS_WAFFLE_SWITCH_NAMESPACE = WaffleSwitchNamespace(name='programs')

# This is meant to be enabled until https://openedx.atlassian.net/browse/LEARNER-5573 needs to be resolved
ALWAYS_CALCULATE_PROGRAM_PRICE_AS_ANONYMOUS_USER = WaffleSwitch(
    PROGRAMS_WAFFLE_SWITCH_NAMESPACE,
    'always_calculate_program_price_as_anonymous_user')
Example #5
0
"""
Contains configuration for schedules app
"""

from openedx.core.djangoapps.waffle_utils import (
    WaffleFlagNamespace,
    CourseWaffleFlag,
    WaffleFlag,
    WaffleSwitch,
    WaffleSwitchNamespace,
)

WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name=u'schedules')
WAFFLE_SWITCH_NAMESPACE = WaffleSwitchNamespace(name=u'schedules')

CREATE_SCHEDULE_WAFFLE_FLAG = CourseWaffleFlag(
    waffle_namespace=WAFFLE_FLAG_NAMESPACE,
    flag_name=u'create_schedules_for_course',
)

COURSE_UPDATE_WAFFLE_FLAG = CourseWaffleFlag(
    waffle_namespace=WAFFLE_FLAG_NAMESPACE,
    flag_name=u'send_updates_for_course',
)

DEBUG_MESSAGE_WAFFLE_FLAG = WaffleFlag(WAFFLE_FLAG_NAMESPACE,
                                       u'enable_debugging')

COURSE_UPDATE_SHOW_UNSUBSCRIBE_WAFFLE_SWITCH = WaffleSwitch(
    WAFFLE_SWITCH_NAMESPACE, u'course_update_show_unsubscribe')
Example #6
0
"""
Feature toggle code for oauth_dispatch.
"""

from __future__ import absolute_import

from edx_rest_framework_extensions.config import OAUTH_TOGGLE_NAMESPACE, SWITCH_ENFORCE_JWT_SCOPES

from openedx.core.djangoapps.waffle_utils import WaffleSwitch, WaffleSwitchNamespace

ENFORCE_JWT_SCOPES = WaffleSwitch(
    WaffleSwitchNamespace(name=OAUTH_TOGGLE_NAMESPACE),
    SWITCH_ENFORCE_JWT_SCOPES)
Example #7
0
""" Course API """

from openedx.core.djangoapps.waffle_utils import WaffleSwitch, WaffleSwitchNamespace

WAFFLE_SWITCH_NAMESPACE = WaffleSwitchNamespace(
    name='course_list_api_rate_limit')

# .. toggle_name: course_list_api_rate_limit.rate_limit_2
# .. toggle_implementation: WaffleSwitch
# .. toggle_default: False
# .. toggle_description: Waffle switch to enable the throttling of 2 requests/minute to the course API. For staff
#   users, this limit is 10 requests/minute.
# .. toggle_use_cases: circuit_breaker
# .. toggle_creation_date: 2018-06-12
# .. toggle_tickets: https://openedx.atlassian.net/browse/LEARNER-5527
USE_RATE_LIMIT_2_FOR_COURSE_LIST_API = WaffleSwitch(WAFFLE_SWITCH_NAMESPACE,
                                                    'rate_limit_2', __name__)
# .. toggle_name: course_list_api_rate_limit.rate_limit_10
# .. toggle_implementation: WaffleSwitch
# .. toggle_default: False
# .. toggle_description: Waffle switch to enable the throttling of 10 requests/minute to the course API. For staff
#   users, this limit is 20 requests/minute.
# .. toggle_use_cases: circuit_breaker
# .. toggle_creation_date: 2018-06-12
# .. toggle_tickets: https://openedx.atlassian.net/browse/LEARNER-5527
USE_RATE_LIMIT_10_FOR_COURSE_LIST_API = WaffleSwitch(WAFFLE_SWITCH_NAMESPACE,
                                                     'rate_limit_10', __name__)
Example #8
0
"""
Waffle flags and switches for user authn.
"""

from openedx.core.djangoapps.waffle_utils import WaffleSwitch, WaffleSwitchNamespace

_WAFFLE_NAMESPACE = u'user_authn'
_WAFFLE_SWITCH_NAMESPACE = WaffleSwitchNamespace(name=_WAFFLE_NAMESPACE,
                                                 log_prefix=u'UserAuthN: ')

# .. toggle_name: user_authn.enable_login_using_thirdparty_auth_only
# .. toggle_implementation: WaffleSwitch
# .. toggle_default: False
# .. toggle_description: When enabled, users must be sign in using their allowed domain SSO account. This includes sign-
#   ins to the Django admin dashboard at "/admin".
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2019-11-20
# .. toggle_target_removal_date: 2020-01-31
# .. toggle_warnings: Requires THIRD_PARTY_AUTH_ONLY_DOMAIN to also be set.
# .. toggle_tickets: ENT-2461
ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY = WaffleSwitch(
    _WAFFLE_SWITCH_NAMESPACE, 'enable_login_using_thirdparty_auth_only',
    __name__)
"""
Feature toggle code for oauth_dispatch.
"""

from __future__ import absolute_import

from edx_rest_framework_extensions.config import SWITCH_ENFORCE_JWT_SCOPES

from openedx.core.djangoapps.waffle_utils import WaffleSwitch, WaffleSwitchNamespace

WAFFLE_NAMESPACE = 'oauth2'
OAUTH2_SWITCHES = WaffleSwitchNamespace(name=WAFFLE_NAMESPACE)
ENFORCE_JWT_SCOPES = WaffleSwitch(OAUTH2_SWITCHES, SWITCH_ENFORCE_JWT_SCOPES)
Example #10
0
_WAFFLE_NAMESPACE = u'user_authn'
_WAFFLE_SWITCH_NAMESPACE = WaffleSwitchNamespace(name=_WAFFLE_NAMESPACE,
                                                 log_prefix=u'UserAuthN: ')

# .. toggle_name: user_authn.enable_login_using_thirdparty_auth_only
# .. toggle_implementation: WaffleSwitch
# .. toggle_default: False
# .. toggle_description: When enabled, users must be sign in using their allowed domain SSO account.
# .. toggle_category: authn
# .. toggle_use_cases: incremental_release
# .. toggle_creation_date: 2019-11-20
# .. toggle_expiration_date: 2020-01-31
# .. toggle_warnings: Requires THIRD_PARTY_AUTH_ONLY_DOMAIN to also be set.
# .. toggle_tickets: ENT-2461
# .. toggle_status: supported
ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY = WaffleSwitch(
    _WAFFLE_SWITCH_NAMESPACE, 'enable_login_using_thirdparty_auth_only')

# .. toggle_name: user_authn.update_login_user_error_status_code
# .. toggle_implementation: WaffleSwitch
# .. toggle_default: False
# .. toggle_description: Changes auth failures (non-SSO) from 200 to 400.
# .. toggle_category: authn
# .. toggle_use_cases: incremental_release
# .. toggle_creation_date: 2019-11-21
# .. toggle_expiration_date: 2020-01-31
# .. toggle_warnings: Causes backward incompatible change. Document before removing.
# .. toggle_tickets: ARCH-1253
# .. toggle_status: supported
UPDATE_LOGIN_USER_ERROR_STATUS_CODE = WaffleSwitch(
    _WAFFLE_SWITCH_NAMESPACE, 'update_login_user_error_status_code')