0001-idp.saml-no-plugin.patch
setup.py | ||
---|---|---|
171 | 171 |
'authentic2.plugin': [ |
172 | 172 |
'authentic2-auth-saml = authentic2_auth_saml:Plugin', |
173 | 173 |
'authentic2-auth-oidc = authentic2_auth_oidc:Plugin', |
174 |
'authentic2-idp-saml2 = authentic2.idp.saml:Plugin', |
|
175 | 174 |
'authentic2-idp-cas = authentic2_idp_cas:Plugin', |
176 | 175 |
'authentic2-idp-oidc = authentic2_idp_oidc:Plugin', |
177 | 176 |
'authentic2-provisionning-ldap = authentic2_provisionning_ldap:Plugin', |
src/authentic2/cors.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
import itertools |
|
17 | 18 |
from .decorators import SessionCache |
18 | 19 | |
20 |
from django.apps import apps |
|
19 | 21 |
from django.conf import settings |
20 | 22 |
from django.utils.six.moves.urllib import parse as urlparse |
21 | 23 | |
... | ... | |
56 | 58 |
for whitelist_origin in app_settings.A2_CORS_WHITELIST: |
57 | 59 |
if whitelist_origin == origin: |
58 | 60 |
return True |
59 |
for plugin in plugins.get_plugins():
|
|
61 |
for plugin in itertools.chain(plugins.get_plugins(), apps.get_app_configs()):
|
|
60 | 62 |
if hasattr(plugin, 'check_origin'): |
61 | 63 |
if plugin.check_origin(request, origin): |
62 | 64 |
return True |
src/authentic2/idp/saml/__init__.py | ||
---|---|---|
19 | 19 |
from django.apps import AppConfig |
20 | 20 | |
21 | 21 | |
22 |
class Plugin(object): |
|
23 |
def get_before_urls(self): |
|
24 |
from . import app_settings |
|
25 |
from django.conf.urls import url, include |
|
26 |
from authentic2.decorators import (setting_enabled, required, |
|
27 |
lasso_required) |
|
28 | ||
29 |
return required( |
|
30 |
( |
|
31 |
setting_enabled('ENABLE', settings=app_settings), |
|
32 |
lasso_required() |
|
33 |
), |
|
34 |
[url(r'^idp/saml2/', include(__name__ + '.urls'))]) |
|
35 | ||
36 |
def get_apps(self): |
|
37 |
return ['authentic2.idp.saml'] |
|
38 | ||
39 |
def get_idp_backends(self): |
|
40 |
return ['authentic2.idp.saml.backend.SamlBackend'] |
|
22 |
class SAML2IdPConfig(AppConfig): |
|
23 |
name = 'authentic2.idp.saml' |
|
24 |
label = 'authentic2_idp_saml' |
|
41 | 25 | |
42 | 26 |
def check_origin(self, request, origin): |
43 | 27 |
from authentic2.cors import make_origin |
... | ... | |
48 | 32 |
if origin == provider_origin: |
49 | 33 |
return True |
50 | 34 | |
51 | ||
52 |
class SAML2IdPConfig(AppConfig): |
|
53 |
name = 'authentic2.idp.saml' |
|
54 |
label = 'authentic2_idp_saml' |
|
55 | 35 |
default_app_config = 'authentic2.idp.saml.SAML2IdPConfig' |
56 | 36 | |
57 | 37 |
src/authentic2/settings.py | ||
---|---|---|
190 | 190 | |
191 | 191 |
# List of IdP backends, mainly used to show available services in the homepage |
192 | 192 |
# of user, and to handle SLO for each protocols |
193 |
IDP_BACKENDS = plugins.register_plugins_idp_backends(()) |
|
193 |
IDP_BACKENDS = ('authentic2.idp.saml.backend.SamlBackend',) + plugins.register_plugins_idp_backends(())
|
|
194 | 194 | |
195 | 195 |
# Whether to autoload SAML 2.0 identity providers and services metadata |
196 | 196 |
# Only https URLS are accepted. |
src/authentic2/urls.py | ||
---|---|---|
24 | 24 |
from django.views.static import serve as media_serve |
25 | 25 | |
26 | 26 |
from . import plugins, views |
27 |
from authentic2.decorators import setting_enabled, required, lasso_required |
|
28 |
import authentic2.idp.saml.app_settings |
|
29 | ||
30 | ||
27 | 31 | |
28 | 32 |
admin.autodiscover() |
29 | 33 | |
... | ... | |
143 | 147 |
] + urlpatterns |
144 | 148 | |
145 | 149 |
urlpatterns = plugins.register_plugins_urls(urlpatterns) |
150 | ||
151 |
authentic2_idp_saml_urls = required( |
|
152 |
( |
|
153 |
setting_enabled('ENABLE', settings=authentic2.idp.saml.app_settings), |
|
154 |
lasso_required() |
|
155 |
), |
|
156 |
[url(r'^idp/saml2/', include('authentic2.idp.saml.urls'))] |
|
157 |
) |
|
158 |
urlpatterns = authentic2_idp_saml_urls + urlpatterns |
|
146 |
- |