|  | 
|  | 1 | +from __future__ import absolute_import | 
|  | 2 | +from __future__ import unicode_literals | 
|  | 3 | + | 
|  | 4 | +from .settings import oauth2_settings | 
|  | 5 | + | 
|  | 6 | + | 
|  | 7 | +class BaseScopes(object): | 
|  | 8 | +    def get_all_scopes(self): | 
|  | 9 | +        """ | 
|  | 10 | +        Return a dict-like object with all the scopes available in the | 
|  | 11 | +        system. The key should be the scope name and the value should be | 
|  | 12 | +        the description. | 
|  | 13 | +
 | 
|  | 14 | +        ex: {"read": "A read scope", "write": "A write scope"} | 
|  | 15 | +        """ | 
|  | 16 | +        raise NotImplementedError("") | 
|  | 17 | + | 
|  | 18 | +    def get_available_scopes(self, application=None, request=None, *args, **kwargs): | 
|  | 19 | +        """ | 
|  | 20 | +        Return a list of scopes available for the current application/request. | 
|  | 21 | +
 | 
|  | 22 | +        TODO: add info on where and why this method is called. | 
|  | 23 | +
 | 
|  | 24 | +        ex: ["read", "write"] | 
|  | 25 | +        """ | 
|  | 26 | +        raise NotImplementedError("") | 
|  | 27 | + | 
|  | 28 | +    def get_default_scopes(self, application=None, request=None, *args, **kwargs): | 
|  | 29 | +        """ | 
|  | 30 | +        Return a list of the default scopes for the current application/request. | 
|  | 31 | +        This MUST be a subset of the scopes returned by `get_available_scopes`. | 
|  | 32 | +
 | 
|  | 33 | +        TODO: add info on where and why this method is called. | 
|  | 34 | +
 | 
|  | 35 | +        ex: ["read"] | 
|  | 36 | +        """ | 
|  | 37 | +        raise NotImplementedError("") | 
|  | 38 | + | 
|  | 39 | + | 
|  | 40 | +class SettingsScopes(BaseScopes): | 
|  | 41 | +    def get_all_scopes(self): | 
|  | 42 | +        return oauth2_settings.SCOPES | 
|  | 43 | + | 
|  | 44 | +    def get_available_scopes(self, application=None, request=None, *args, **kwargs): | 
|  | 45 | +        return oauth2_settings._SCOPES | 
|  | 46 | + | 
|  | 47 | +    def get_default_scopes(self, application=None, request=None, *args, **kwargs): | 
|  | 48 | +        return oauth2_settings._DEFAULT_SCOPES | 
|  | 49 | + | 
|  | 50 | + | 
|  | 51 | +def get_scopes_backend(): | 
|  | 52 | +    scopes_class = oauth2_settings.SCOPES_BACKEND_CLASS | 
|  | 53 | +    return scopes_class() | 
0 commit comments