Rename setting.

This commit is contained in:
juanifioren 2015-06-24 12:40:00 -03:00
parent 4021441c76
commit 197818566d
6 changed files with 20 additions and 20 deletions

View file

@ -5,8 +5,8 @@ All notable changes to this project will be documented in this file.
### [Unreleased] ### [Unreleased]
##### Added ##### Added
- Way of remember user consent and skipt it (OIDC_USER_CONSENT_ENABLE). - Way of remember user consent and skipt it (OIDC_SKIP_CONSENT_ENABLE).
- Setting OIDC_USER_CONSENT_EXPIRE. - Setting OIDC_SKIP_CONSENT_EXPIRE.
##### Changed ##### Changed
- Now OIDC_EXTRA_SCOPE_CLAIMS must be a string, to be lazy imported. - Now OIDC_EXTRA_SCOPE_CLAIMS must be a string, to be lazy imported.

10
DOC.md
View file

@ -3,7 +3,7 @@
Django OIDC Provider can help you providing out of the box all the endpoints, data and logic needed to add OpenID Connect capabilities to your Django projects. Django OIDC Provider can help you providing out of the box all the endpoints, data and logic needed to add OpenID Connect capabilities to your Django projects.
**This project is still in DEVELOPMENT and is rapidly changing. DO NOT USE IT FOR PRODUCTION SITES, unless you know what you do.** **This project is still in DEVELOPMENT and is rapidly changing.**
**************************************** ****************************************
@ -25,9 +25,9 @@ Before getting started there are some important things that you should know:
- [OIDC_EXTRA_SCOPE_CLAIMS](#oidc_extra_scope_claims) - [OIDC_EXTRA_SCOPE_CLAIMS](#oidc_extra_scope_claims)
- [OIDC_IDTOKEN_EXPIRE](#oidc_idtoken_expire) - [OIDC_IDTOKEN_EXPIRE](#oidc_idtoken_expire)
- [OIDC_IDTOKEN_SUB_GENERATOR](#oidc_idtoken_sub_generator) - [OIDC_IDTOKEN_SUB_GENERATOR](#oidc_idtoken_sub_generator)
- [OIDC_SKIP_CONSENT_ENABLE](#oidc_skip_consent_enable)
- [OIDC_SKIP_CONSENT_EXPIRE](#oidc_skip_consent_expire)
- [OIDC_TOKEN_EXPIRE](#oidc_token_expire) - [OIDC_TOKEN_EXPIRE](#oidc_token_expire)
- [OIDC_USER_CONSENT_ENABLE](#oidc_user_consent_enable)
- [OIDC_USER_CONSENT_EXPIRE](#oidc_user_consent_expire)
- [Users And Clients](#users-and-clients) - [Users And Clients](#users-and-clients)
- [Templates](#templates) - [Templates](#templates)
- [Server Endpoints](#server-endpoints) - [Server Endpoints](#server-endpoints)
@ -35,8 +35,8 @@ Before getting started there are some important things that you should know:
## Requirements ## Requirements
- Python 2.7.*. - Python: `2.7.*`
- Django 1.7.*. - Django: `1.7.*` `1.8.*`
## Installation ## Installation

View file

@ -148,7 +148,7 @@ class AuthorizeEndpoint(object):
Return None. Return None.
""" """
expires_at = timezone.now() + timedelta( expires_at = timezone.now() + timedelta(
days=settings.get('OIDC_USER_CONSENT_EXPIRE')) days=settings.get('OIDC_SKIP_CONSENT_EXPIRE'))
uc, created = UserConsent.objects.get_or_create( uc, created = UserConsent.objects.get_or_create(
user=self.request.user, user=self.request.user,

View file

@ -61,26 +61,26 @@ class DefaultSettings(object):
return default_sub_generator return default_sub_generator
@property @property
def OIDC_TOKEN_EXPIRE(self): def OIDC_SKIP_CONSENT_ENABLE(self):
"""
OPTIONAL.
"""
return 60*60
@property
def OIDC_USER_CONSENT_ENABLE(self):
""" """
OPTIONAL. OPTIONAL.
""" """
return True return True
@property @property
def OIDC_USER_CONSENT_EXPIRE(self): def OIDC_SKIP_CONSENT_EXPIRE(self):
""" """
OPTIONAL. OPTIONAL.
""" """
return 30*3 return 30*3
@property
def OIDC_TOKEN_EXPIRE(self):
"""
OPTIONAL.
"""
return 60*60
default_settings = DefaultSettings() default_settings = DefaultSettings()

View file

@ -244,10 +244,10 @@ class AuthorizationCodeFlowTestCase(TestCase):
# Ensure user consent skip is enabled. # Ensure user consent skip is enabled.
OIDC_AFTER_USERLOGIN_HOOK = settings.default_settings.OIDC_AFTER_USERLOGIN_HOOK OIDC_AFTER_USERLOGIN_HOOK = settings.default_settings.OIDC_AFTER_USERLOGIN_HOOK
OIDC_USER_CONSENT_ENABLE = settings.default_settings.OIDC_USER_CONSENT_ENABLE OIDC_SKIP_CONSENT_ENABLE = settings.default_settings.OIDC_SKIP_CONSENT_ENABLE
with self.settings( with self.settings(
OIDC_AFTER_USERLOGIN_HOOK=OIDC_AFTER_USERLOGIN_HOOK, OIDC_AFTER_USERLOGIN_HOOK=OIDC_AFTER_USERLOGIN_HOOK,
OIDC_USER_CONSENT_ENABLE=OIDC_USER_CONSENT_ENABLE): OIDC_SKIP_CONSENT_ENABLE=OIDC_SKIP_CONSENT_ENABLE):
response = AuthorizeView.as_view()(request) response = AuthorizeView.as_view()(request)
is_code_ok = is_code_valid(url=response['Location'], is_code_ok = is_code_valid(url=response['Location'],

View file

@ -34,7 +34,7 @@ class AuthorizeView(View):
if hook_resp: if hook_resp:
return hook_resp return hook_resp
if settings.get('OIDC_USER_CONSENT_ENABLE'): if settings.get('OIDC_SKIP_CONSENT_ENABLE'):
# Check if user previously give consent. # Check if user previously give consent.
if authorize.client_has_user_consent(): if authorize.client_has_user_consent():
uri = authorize.create_response_uri() uri = authorize.create_response_uri()