Add verbose name and description for scopes.
This commit is contained in:
parent
d4f25c3dd2
commit
4cc7474c19
5 changed files with 73 additions and 12 deletions
|
@ -54,12 +54,23 @@ OpenID Connect Clients will use scope values to specify what access privileges a
|
|||
|
||||
`Here <http://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims>`_ you have the standard scopes defined by the protocol.
|
||||
|
||||
You can create or modify scopes using:
|
||||
|
||||
* ``info_scopename`` class property for setting the verbose name and description.
|
||||
* ``scope_scopename`` method for returning some information related.
|
||||
|
||||
Check out an example of how to implement it::
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from oidc_provider.lib.claims import ScopeClaims
|
||||
|
||||
class MyAppScopeClaims(ScopeClaims):
|
||||
|
||||
info_books = (
|
||||
_(u'Books'), # Verbose name of the scope.
|
||||
_(u'Access to your books.'), # Description of the scope.
|
||||
)
|
||||
|
||||
def scope_books(self):
|
||||
# Here, for example, you can search books for this user.
|
||||
# self.user - Django user instance.
|
||||
|
@ -72,11 +83,14 @@ Check out an example of how to implement it::
|
|||
|
||||
return dic
|
||||
|
||||
You can create our own scopes using the convention:
|
||||
# If you want to change the description of the profile scope, you can redefine it.
|
||||
info_profile = (
|
||||
_(u'Profile'),
|
||||
_(u'Another description.'),
|
||||
)
|
||||
|
||||
``def scope_somename(self):``
|
||||
|
||||
If a field is empty or ``None`` will be cleaned from the response.
|
||||
.. note::
|
||||
If a field is empty or ``None`` inside the dictionary your return on ``scope_scopename`` method, it will be cleaned from the response.
|
||||
|
||||
OIDC_IDTOKEN_EXPIRE
|
||||
===================
|
||||
|
@ -93,9 +107,9 @@ OPTIONAL. ``str`` or ``(list, tuple)``.
|
|||
A string with the location of your function hook or ``list`` or ``tuple`` with hook functions.
|
||||
Here you can add extra dictionary values specific for your app into id_token.
|
||||
|
||||
The ``list`` or ``tuple`` is useful when You want to set multiple hooks, i.e. one for permissions and second for some special field.
|
||||
The ``list`` or ``tuple`` is useful when you want to set multiple hooks, i.e. one for permissions and second for some special field.
|
||||
|
||||
The function receives a ``id_token`` dictionary and ``user`` instance
|
||||
The function receives a ``id_token`` dictionary and ``user`` instance
|
||||
and returns it with additional fields.
|
||||
|
||||
Default is::
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue