From 6e348a7450b7b4eab0b15e82e5ac4c8f0b12a315 Mon Sep 17 00:00:00 2001 From: rmichaelis Date: Fri, 30 Jan 2015 11:56:12 +0100 Subject: [PATCH 01/13] Add missing librairies --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d94467f4d..03e0be798 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,9 @@ url='http://www.camptocamp.com/geospatial-solutions', install_requires=[ 'c2cgeoportal>=1.6.0dev-20141210', - 'elasticsearch' + 'elasticsearch', + 'python-ldap', + 'pyramid_ldap' ], packages=find_packages(exclude=['ez_setup']), include_package_data=True, From dc052434eed0a5364030b6137566331b4fbff857 Mon Sep 17 00:00:00 2001 From: rmichaelis Date: Tue, 3 Feb 2015 16:45:35 +0100 Subject: [PATCH 02/13] authenticates against ldap --- geoportailv3/views/authentication.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 geoportailv3/views/authentication.py diff --git a/geoportailv3/views/authentication.py b/geoportailv3/views/authentication.py new file mode 100644 index 000000000..1c9bd7700 --- /dev/null +++ b/geoportailv3/views/authentication.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- + + +def ldap_user_validator(request, username, password): + from pyramid_ldap import get_ldap_connector + connector = get_ldap_connector(request) + data = connector.authenticate(username, password) + if data is not None: + return data[0] + return None From b25b9d4c7458e7665bb9d6c071a88f960c14d37c Mon Sep 17 00:00:00 2001 From: rmichaelis Date: Tue, 3 Feb 2015 18:05:24 +0100 Subject: [PATCH 03/13] add ldap config --- geoportailv3.mk | 2 ++ geoportailv3/__init__.py | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/geoportailv3.mk b/geoportailv3.mk index 7613ec96c..4dbf598c6 100644 --- a/geoportailv3.mk +++ b/geoportailv3.mk @@ -16,6 +16,8 @@ PRINT3 = FALSE DISABLE_BUILD_RULES = test-packages test-packages-ngeo +CONFIG_VARS += ldap_url ldap_bind ldap_passwd ldap_base_dn + include CONST_Makefile DEV_REQUIREMENTS += git+https://github.com/transifex/transifex-client.git@fix-proxies#egg=transifex-client-proxies diff --git a/geoportailv3/__init__.py b/geoportailv3/__init__.py index 92f579351..23a1f7a25 100644 --- a/geoportailv3/__init__.py +++ b/geoportailv3/__init__.py @@ -3,11 +3,13 @@ from pyramid.config import Configurator from pyramid.settings import asbool from c2cgeoportal import locale_negotiator, \ - add_interface, INTERFACE_TYPE_NGEO_CATALOGUE + add_interface, INTERFACE_TYPE_NGEO_CATALOGUE, \ + set_user_validator from c2cgeoportal.resources import FAModels from c2cgeoportal.lib.authentication import create_authentication from geoportailv3.resources import Root - +from geoportailv3.views.authentication import ldap_user_validator +import ldap def main(global_config, **settings): """ This function returns a Pyramid WSGI application. @@ -22,6 +24,22 @@ def main(global_config, **settings): config.include('c2cgeoportal') config.include('pyramid_closure') + config.include('pyramid_ldap') + + """Config the ldap connection. + """ + config.ldap_setup( + config.get_settings()['ldap_url'], + config.get_settings()['ldap_bind'], + config.get_settings()['ldap_passwd'], + ) + + config.ldap_set_login_query( + config.get_settings()['ldap_base_dn'], + filter_tmpl='(login=%(login)s)', + scope = ldap.SCOPE_SUBTREE, + ) + set_user_validator(config, ldap_user_validator) config.add_translation_dirs('geoportailv3:locale/') From d9d14647ab159e9d87d46d806db55722f7390f77 Mon Sep 17 00:00:00 2001 From: rmichaelis Date: Tue, 3 Feb 2015 18:07:16 +0100 Subject: [PATCH 04/13] authentication does not use the one provided in CONST_vars.yaml --- development.ini.in | 2 ++ production.ini.in | 2 ++ 2 files changed, 4 insertions(+) diff --git a/development.ini.in b/development.ini.in index 1e838fe14..61aa1d4bc 100644 --- a/development.ini.in +++ b/development.ini.in @@ -11,6 +11,8 @@ mako.directories = geoportailv3:templates app.cfg = %(here)s/.build/config.yaml elastic.servers = ${search_host} elastic.index = ${search_index} +authtkt_secret = ${authtkt_secret} +authtkt_cookie_name = ${authtkt_cookie_name} # pyramid_closure configuration pyramid_closure.roots = diff --git a/production.ini.in b/production.ini.in index 2bc4ba033..462f5fecd 100644 --- a/production.ini.in +++ b/production.ini.in @@ -9,6 +9,8 @@ debug_templates = false mako.directories = geoportailv3:templates c2cgeoportal:templates app.cfg = %(here)s/.build/config.yaml +authtkt_secret = ${authtkt_secret} +authtkt_cookie_name = ${authtkt_cookie_name} [filter:weberror] use = egg:WebError#error_catcher From fd2131d350636f23d3184871312ba2dfd1c45c64 Mon Sep 17 00:00:00 2001 From: rmichaelis Date: Thu, 5 Feb 2015 10:35:12 +0100 Subject: [PATCH 05/13] layout first draft --- geoportailv3/static/js/maincontroller.js | 5 + geoportailv3/static/less/icons.less | 2 +- geoportailv3/static/less/layout.less | 140 +++++++++++++++++++++++ geoportailv3/static/less/theme.less | 47 ++++++++ geoportailv3/templates/index.html | 23 +++- 5 files changed, 215 insertions(+), 2 deletions(-) diff --git a/geoportailv3/static/js/maincontroller.js b/geoportailv3/static/js/maincontroller.js index 9174b54e8..e3a17538b 100644 --- a/geoportailv3/static/js/maincontroller.js +++ b/geoportailv3/static/js/maincontroller.js @@ -93,6 +93,11 @@ app.MainController = function($scope, gettextCatalog, langUrlTemplate, */ this['shareOpen'] = false; + /** + * @type {Boolean} + */ + this['userOpen'] = false; + /** * @type {Array} */ diff --git a/geoportailv3/static/less/icons.less b/geoportailv3/static/less/icons.less index a6abcbeec..d5c617578 100644 --- a/geoportailv3/static/less/icons.less +++ b/geoportailv3/static/less/icons.less @@ -80,7 +80,7 @@ button.icon.search:after, .icon.share a:after { content: '\e02a'; } -.icon.user a:after { +.icon.user > a:after { content: '\e02d'; } .icon.lang > a:after { diff --git a/geoportailv3/static/less/layout.less b/geoportailv3/static/less/layout.less index 03ae7ab7b..a4f438e7c 100644 --- a/geoportailv3/static/less/layout.less +++ b/geoportailv3/static/less/layout.less @@ -144,3 +144,143 @@ div.ol-full-screen > button { div.ol-zoom-extent > button { text-indent: 4px; } + +.user-experience { + display: inline-block; + float: right; + margin: 0; + padding: 0; +} + +.user-experience ul { + margin: 0; + padding: 0; +} + +.user-experience li { + display: inline-block; + float: left; + background-repeat: no-repeat; + background-position: 1px top; +} + +.user-experience > li > a { + border-left: 1px solid #8394a0; + color: #96A2AE; + position:relative; + text-indent: -999em; +} + +.user-experience > li > a:hover, +.user-experience > li >a:focus { + text-decoration:none; +} + +.user-experience > li > a:after { + font-family: "geoportail-icons"; + font-size: 2em; + position: absolute; + top: 18px; + left: 0; + width: 100%; + text-align: center; + text-indent: 0; +} + +.user-experience .user > a:after { + content: '\e02d'; +} +.user-experience .open > .item:after { + content: '\e02b'; +} + +.user-experience > .open > .item:hover { + background-color: #fff !important; + color:#8394A0; +} + + +.user-experience .second-level { + display: none; + position: absolute; + right: 0px; + text-align: left; + z-index: 10; + width: 320px; +} + +.user-experience .second-level li { + border-left-width: 0px; +} + +.user-experience .open .second-level { + display:block; +} + +.user-experience .second-level .item { + line-height: 63px; +} + +.user-experience .second-level .current .item, +.user-experience .second-level .item:hover {text-decoration: none; background-color: #fff !important; color:#96a2ae; } +.user-experience .menu-title { margin: 18px 0px; padding-left: 10px; text-transform: uppercase; font-family:'DINNextLTPro-Condensed', Arial, sans-serif; font-size: 40px; } + +.navigation-account { padding: 10px;} +.user-experience input { height: 43px; border: none; } +.user-experience input[type=password], +.user-experience input[type=text] { float:left; width:100%; margin-bottom: 10px; padding: 17px 10px 10px; background-color: rgba(46,65,78, 0.2); text-transform: uppercase; font-size: 16px; + -webkit-box-shadow: inset 0px 2px 4px -1px rgba(0, 57, 79, 0.25); + box-shadow: inset 0px 2px 4px -1px rgba(0, 57, 79, 0.25); +} + +.user-experience .user [data-notifications]:before { z-index:10; content:attr(data-notifications); position:absolute; display:block; top:26px; left:34px; color:#fff; text-indent: 0; background-color:#63a4ce; min-width:21px; height:21px; line-height:21px; font-size:16px; text-align:center; border-radius:50%; } +.user-experience .user.open > [data-notifications]:before { display:none; } +.user-experience .user .item { position:relative; } + +.navigation-account { padding: 10px 0px 0px; font-family:'DINNextLTPro-Condensed', Arial, sans-serif; } +.navigation-account .menu-title { padding: 0px 20px; } +.account-content { padding: 10px; clear:both; } +.navigation-account .tab { margin:0px;float:left; text-indent:-999em; position:relative; width: 41px; height:41px; line-height: 41px; padding: 0px 10px 0px 20px; margin-left:1px; text-transform: uppercase; font-size:24px; color: #fff; cursor:pointer; } +.navigation-account .tab:hover, + +.navigation-account .tab-account { width:82px; } +.navigation-account .tab[data-notifications]:before{ top:-10px; left:10px; } + +.navigation-account.logged-in .tab { text-align: center; padding-left: 10px;} +.navigation-account input[type=submit] { float: right; width: 91px; height:44px; line-height:44px; text-align:center; border:none; color:#fff; text-transform:uppercase; font-size: 16px; font-family:'DINNextLTPro-Condensed',Arial,sans-serif; } +.navigation-account p { margin: 0px; } +.navigation-account .tab:after { + font-family: "geoportail-icons"; + font-size:28px; + line-height:41px; + color:#fff; + position:absolute; + width:100%; + text-align:center; + text-indent:0; + position:absolute; + top:0; + left:0; + content:'\e02d'; +} + + +.account-content > ul li { float: none; display: block; height: auto; line-height: 31px; margin-bottom: 1px; position:relative; } +.account-content > ul li:hover { background-color:#fff; } +.account-content > ul li a { display: block; height: auto; line-height: 31px; padding: 0px 50px 0px 10px; color: #fff; } +.account-content > ul li:hover a { text-decoration: none; background-position: 258px bottom; } + +.navigation-account fieldset { + border: 0; + margin: 0; + padding: 0; +} +.navigation-account .account-content p { + white-space: normal; +} + +.navigation-account legend { + border: 0 none; + padding: 0; + white-space: normal; +} diff --git a/geoportailv3/static/less/theme.less b/geoportailv3/static/less/theme.less index 983b18a1a..7a975e9d7 100644 --- a/geoportailv3/static/less/theme.less +++ b/geoportailv3/static/less/theme.less @@ -115,6 +115,53 @@ color: white; } + .user-experience > li:hover > a { + background-color: @secondary-color; + color: white; + } + .user-experience .open > .item { + background-color: @secondary-color; + color: white; + } + + .user-experience .second-level .item { + background-color: @secondary-color; + color: white; + } + .navigation-account { + background-color: @secondary-color; + } + .navigation-account .account-content > ul li { + background-color: @secondary-color; + } + .navigation-account .account-content > ul li:hover a { + background-color: @secondary-color; + } + .navigation-account input[type=submit] { + background-color: @secondary-color; + } + .navigation-account .tab { + background-color: @primary-color; + } + .navigation-account .tab:hover[data-notifications]:before, + .navigation-account .tab.active[data-notifications]:before { + background-color: @primary-color; + } + .navigation-account input[type=submit]:hover { + color: @tertiary-color; + } + .account-content { + background-color: @primary-color; + } + .navigation-account .tab.active { background-color:@primary-color; + } + .user-experience .menu-title { + color: white; + } + .user-experience input { + color: white; + } + } } diff --git a/geoportailv3/templates/index.html b/geoportailv3/templates/index.html index b7a8d209b..1cf229f5f 100644 --- a/geoportailv3/templates/index.html +++ b/geoportailv3/templates/index.html @@ -28,7 +28,28 @@