Commit 9f2cad09 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add authentication procedure using base tool provide by web2py.

parent d2c421cf
......@@ -2,7 +2,7 @@
"""
#@auth.requires_membership('track_publications')
@auth.requires_login()
def index():
session.role = 'admin'
return LOAD('plugin_dbui', 'index', vars=request.vars)
......@@ -6,6 +6,24 @@ def index():
session.role = 'user'
return LOAD('plugin_dbui', 'index', vars=request.vars)
def user():
"""
exposes:
http://..../[app]/default/user/login
http://..../[app]/default/user/logout
http://..../[app]/default/user/register
http://..../[app]/default/user/profile
http://..../[app]/default/user/retrieve_password
http://..../[app]/default/user/change_password
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""
return dict(form=auth())
def versions():
dbui = local_import('plugin_dbui')
return dbui.get_versions()
......@@ -22,7 +22,10 @@
'CPPM': 'CPPM',
'Cannot be empty': 'Cannot be empty',
'Category': 'Catégorie',
'Change password': 'Change password',
'Chapter(s)': 'Chaptitre(s)',
'Check to delete': 'Check to delete',
'Client IP': 'Client IP',
'Code': 'Code',
'Collaboration': 'Collaboration',
'Collections': 'Collections',
......@@ -32,6 +35,7 @@
'Cotutelle': 'Cotutelle',
'Country': 'Pays',
'Cppm Flag': 'CPPM',
'Created On': 'Created On',
'Date': 'Date',
'Date of submission to a publisher: 13 Dec 2011': 'Date de soumission à un éditeur : 13 Dec 2011',
'Dates': 'Dates',
......@@ -40,38 +44,63 @@
'Definition': 'Définition',
'Degree': 'Degree',
'Delete:': 'Delete:',
'Description': 'Description',
'Diploma': 'Diplome',
'Direct access to the table: ': 'Accès direct à la table : ',
'Directors': 'Directeurs',
'E-mail': 'E-mail',
'Edit current record': 'Edit current record',
'Filter cppm_authors': 'Filtrer les auteurs du CPPM',
'Filter diplomas': 'Filtrer les diplomes',
'Filter publications': 'Filtrer les publications',
'First Author': 'Premier Auteur',
'First name': 'First name',
'Format': 'Format',
'Forms': 'Formulaires',
'Grids': 'Tables',
'Group %(group_id)s created': 'Group %(group_id)s created',
'Group ID': 'Group ID',
'Group uniquely assigned to user %(id)s': 'Group uniquely assigned to user %(id)s',
'Host': 'Host',
'ISBN': 'ISBN',
'ISSN': 'ISSN',
'Id': 'Id',
'Import/Export': 'Importer/Exporter',
'Invalid email': 'Invalid email',
'Invalid login': 'Invalid login',
'Invalid password': 'Invalid password',
'Last name': 'Last name',
'Level': 'Niveau',
'List': 'Liste',
'List of authors separated by comma: J. Doe, P.-Y. Smith': 'Liste des auteurs séparé par une virgule : J. Doe, P.-Y. Smith',
'List of collections separated by commma: LHCb Papers, LHCb Talks': 'Liste des collections separé par une virgule : LHCb Papers, LHCb Talks',
'Logged in': 'Logged in',
'Logged out': 'Logged out',
'Login': 'Login',
'Logout': 'Logout',
'Lost Password': 'Lost Password',
'Lost password?': 'Lost password?',
'Metric': 'Métrique',
'Name': 'Nom',
'New password': 'New password',
'Nom': 'Nom',
'Notes and Reports to Committees': 'Notes et Rapports à des Comités',
'Notes and reports to committees': 'Notes et Rapports à des Comités',
'Number for the first pages or a range 69-80': 'Numéro de la première page ou un range 69-80',
'Number(s)': 'Numéro(s)',
'Object or table name': 'Object or table name',
'Old password': 'Old password',
'Origin': 'Origin',
'Pages': 'Pages',
'Parameter for fuzzy string search.': 'Paramètre pour la comparaison des chaînes de caractères.',
'Password': 'Password',
"Password fields don't match": "Password fields don't match",
'PhDs': 'PhDs',
'Preprint': 'Preprint',
'Preprint identifier separated by comma: arXiv:0906.1516': 'Numéro(s) du preprint séparé par des virgules: arXiv:0906.1516',
'Preprints': 'Preprints',
'Proceedings': 'Actes de conférence',
'Profile': 'Profile',
'Project': 'Projet',
'Projects': 'Projets',
'Publication': 'Publication',
......@@ -80,12 +109,23 @@
'Publisher': 'Éditeur',
'Query:': 'Query:',
'Ratio': 'Ratio',
'Record ID': 'Record ID',
'Register': 'Register',
'Registration identifier': 'Registration identifier',
'Registration is pending approval': 'Registration is pending approval',
'Registration key': 'Registration key',
'Renew': 'Renew',
'Report': 'Rapport',
'Report identifier separated by comma: LHCb-PROC-2008-04': 'Numéro(s) du rapport séparé par des virgules : LHCb-PROC-2008-04',
'Reports': 'Rapport',
'Request reset password': 'Request reset password',
'Reset Password key': 'Reset Password key',
'Role': 'Rôle',
'Rows in table': 'Rows in table',
'Rôle': 'Rôle',
'Save profile': 'Save profile',
'Select': 'Selectionner',
'Service': 'Service',
'Speaker': 'Orateur',
'Status': 'Status',
'Store': 'Entrepot',
......@@ -104,6 +144,8 @@
'The title of the publication. Use the latex syntax for symbol: $lpha$': 'The title of the publication. Use the latex syntax for symbol: $lpha$',
'The title of the publication. Use the latex syntax for symbol: $\alpha$': 'The title of the publication. Use the latex syntax for symbol: $\alpha$',
'The volume number: 123': 'The volume number: 123',
'Ticket': 'Ticket',
'Timestamp': 'Timestamp',
'Title': 'Titre',
'Tools': 'Outils',
'Town': 'Ville',
......@@ -113,12 +155,27 @@
'Update:': 'Update:',
'Url': 'Url',
'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.': 'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.',
'User %(id)s Logged-in': 'User %(id)s Logged-in',
'User %(id)s Logged-out': 'User %(id)s Logged-out',
'User %(id)s Password changed': 'User %(id)s Password changed',
'User %(id)s Password reset': 'User %(id)s Password reset',
'User %(id)s Profile updated': 'User %(id)s Profile updated',
'User %(id)s Registered': 'User %(id)s Registered',
'User ID': 'User ID',
'Verify Password': 'Verify Password',
'Volume': 'Volume',
'Welcome': 'Welcome',
'XML string describing one MARC12 record.': 'Chaîne de charactère XML définissant un enregistrement MARC12.',
'Xml': 'Xml',
'Year': 'Année',
'Year End': 'Année de fin',
'Year Start': 'Année de début',
'auth_cas': 'auth_cas',
'auth_event': 'auth_event',
'auth_group': 'auth_group',
'auth_membership': 'auth_membership',
'auth_permission': 'auth_permission',
'auth_user': 'auth_user',
'authors_roles': 'rôles des auteurs',
'basic': 'basic',
'cache': 'cache',
......@@ -126,14 +183,17 @@
'collaborations': 'collaborations',
'countries': 'pays',
'cppm_authors': 'autheurs du cppm',
'database': 'database',
'database %s select': 'database %s select',
'db': 'db',
'design': 'design',
'diplomas': 'diplomes',
'done!': 'done!',
'enter a number between %(min)g and %(max)g': 'enter a number between %(min)g and %(max)g',
'enter an integer between %(min)g and %(max)g': 'entrez un entier entre %(min)g et %(max)g',
'enter an integer greater than or equal to %(min)g': 'entrez un entier plus grand ou égual à %(min)g',
'export as csv file': 'exporter un fichier CSV',
'forgot username?': 'forgot username?',
'get lists': 'Obtenir des listes',
'get metrics': 'Obtenir des metriques',
'harvesters': 'moissonneurs',
......@@ -146,10 +206,12 @@
'marc12': 'marc12',
'metrics': 'métriques',
'or import from csv file': 'or import from csv file',
'please input your password again': 'please input your password again',
'plugin not install': 'plugin not install',
'projects': 'projets',
'publications': 'publications',
'publishers': 'éditeurs',
'record id': 'record id',
'reports': 'rapports',
'run harvesters': 'exécuter les moissonneurs',
'select cppm authors for the project': 'sélectionnez les auteurs du cppm pour le projet',
......@@ -171,6 +233,7 @@
'selected': 'sélectionnez',
'state': 'state',
'status': 'status',
'table': 'table',
'team': 'équipe',
'teams': 'équipes',
'total': 'total',
......
from gluon.tools import Auth
DB_MYSQL = 'mysql://GesProd:Prod_CPPM@maretude.in2p3.fr/GesProd'
DB_USERS = 'sqlite:///lhcb/users/legac/mywap/web2py/track_users/databases/storage.sqlite'
#
# Main database
......@@ -14,19 +13,13 @@ except:
#db = DAL('sqlite://storage.sqlite', migrate=True)
#
# Authentification
# Logging
#
#try:
# dbu = DAL(DB_USERS, migrate=False)
#
#except:
# raise HTTP(500, T("Can't access the users database !!!"))
#
#
#auth = Auth(dbu, hmac_key=Auth.get_or_create_key())
#
#auth.define_tables()
#auth.settings.registration_requires_verification = False
#auth.settings.registration_requires_approval = True
#auth.settings.remember_me_form = False
#auth.settings.reset_password_requires_verification = True
\ No newline at end of file
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables(migrate=True)
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = True
auth.settings.remember_me_form = False
auth.settings.reset_password_requires_verification = True
\ No newline at end of file
......@@ -334,22 +334,29 @@ storeModifier = dbui.StoreModifier('teams')
storeModifier.orderby(db.teams.team)
#
# The access to the database tables depends on the user role
# Hide authentication tables
# Hide other tables depending on the user role
#
hidden_tables = []
hidden_tables = ['auth_cas',
'auth_event',
'auth_group',
'auth_membership',
'auth_permission',
'auth_user']
if session.role != 'admin':
hidden_tables = ['authors_roles',
'categories',
'collaborations',
'countries',
'cppm_authors',
'harvesters',
'levels',
'projects',
'publishers',
'reports',
'status',
'teams']
hidden_tables.extend(['authors_roles',
'categories',
'collaborations',
'countries',
'cppm_authors',
'harvesters',
'levels',
'projects',
'publishers',
'reports',
'status',
'teams'])
#
# The form node of the navigation tree
......
......@@ -3,7 +3,8 @@
HEAD
- Rename the table degrees as levels in order to run with MySQL.
- Connection to the database and authenfication move in the access.py files.
- Add authentication procedure using base tools provide by web2py.
- Connection to the database and authentication move in the access.py file.
- Sort the content of all tables (alphabetic, order of arrival, ...).
- Activate the Double click to start the RowEditor in update mode.
- Dedicated page to show version numbers.
......
.calendar{z-index:99;position:relative;display:none;background:#fff;border:2px solid #000;font-size:11px;color:#000;cursor:default;font-family:Arial,Helvetica,sans-serif;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
}.calendar table{margin:0px;font-size:11px;color:#000;cursor:default;font-family:tahoma,verdana,sans-serif;}.calendar .button{text-align:center;padding:1px;color:#fff;background:#000;}.calendar .nav{background:#000;color:#fff}.calendar thead .title{font-weight:bold;padding:1px;background:#000;color:#fff;text-align:center;}.calendar thead .name{padding:2px;text-align:center;background:#bbb;}.calendar thead .weekend{color:#f00;}.calendar thead .hilite {background-color:#666;}.calendar thead .active{padding:2px 0 0 2px;background-color:#c4c0b8;}.calendar tbody .day{width:2em;text-align:right;padding:2px 4px 2px 2px;}.calendar tbody .day.othermonth{color:#aaa;}.calendar tbody .day.othermonth.oweekend{color:#faa;}.calendar table .wn{padding:2px 3px 2px 2px;background:#bbb;}.calendar tbody .rowhilite td{background:#ddd;}.calendar tbody td.hilite{background:#bbb;}.calendar tbody td.active{background:#bbb;}.calendar tbody td.selected{font-weight:bold;background:#ddd;}.calendar tbody td.weekend{color:#f00;}.calendar tbody td.today{font-weight:bold;color:#00f;}.calendar tbody .disabled{color:#999;}.calendar tbody .emptycell{visibility:hidden;}.calendar tbody .emptyrow{display:none;}.calendar tfoot .ttip{background:#bbb;padding:1px;background:#000;color:#fff;text-align:center;}.calendar tfoot .hilite{background:#ddd;}.calendar tfoot .active{}.calendar .combo{position:absolute;display:none;width:4em;top:0;left:0;cursor:default;background:#e4e0d8;padding:1px;z-index:100;}.calendar .combo .label,.calendar .combo .label-IEfix{text-align:center;padding:1px;}.calendar .combo .label-IEfix{width:4em;}.calendar .combo .active{background:#c4c0b8;}.calendar .combo .hilite{background:#048;color:#fea;}.calendar td.time{padding:1px 0;text-align:center;background-color:#bbb;}.calendar td.time .hour,.calendar td.time .minute,.calendar td.time .ampm{padding:0 3px 0 4px;font-weight:bold;}.calendar td.time .ampm{text-align:center;}.calendar td.time .colon{padding:0 2px 0 3px;font-weight:bold;}.calendar td.time span.hilite{}.calendar td.time span.active{border-color:#f00;background-color:#000;color:#0f0;}.hour,.minute{font-size:2em;}
#CP_hourcont{z-index:99;padding:0;position:absolute;border:1px dashed #666;background-color:#eee;display:none;}#CP_minutecont{z-index:99;background-color:#ddd;padding:1px;position:absolute;width:45px;display:none;}.floatleft{float:left;}.CP_hour{z-index:99;padding:1px;font-family:Arial,Helvetica,sans-serif;font-size:9px;white-space:nowrap;cursor:pointer;width:35px;}.CP_minute{z-index:99;padding:1px;font-family:Arial,Helvetica,sans-serif;font-size:9px;white-space:nowrap;cursor:pointer;width:auto;}.CP_over{background-color:#fff;z-index:99}
This diff is collapsed.
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin: 0;
padding: 0;
list-style: none;
}
.sf-menu {
line-height: 1.0;
}
.sf-menu ul {
position: absolute;
top: -999em;
width: 10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
width: 100%;
}
.sf-menu li:hover {
visibility: inherit; /* fixes IE7 'sticky bug' */
}
.sf-menu li {
float: left;
position: relative;
}
.sf-menu a {
padding: 5px;
display: block;
position: relative;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
left: 0;
top: 26px; /* match top ul list item height */
z-index: 99;
}
ul.sf-menu li:hover li ul,
ul.sf-menu li.sfHover li ul {
top: -999em;
}
ul.sf-menu li li:hover ul,
ul.sf-menu li li.sfHover ul {
left: 10em; /* match ul width */
top: 0;
}
ul.sf-menu li li:hover li ul,
ul.sf-menu li li.sfHover li ul {
top: -999em;
}
ul.sf-menu li li li:hover ul,
ul.sf-menu li li li.sfHover ul {
left: 10em; /* match ul width */
top: 0;
}
/*** DEMO SKIN ***/
.sf-menu {
float: left;
/*margin-bottom: 1em;*/
}
.sf-menu a {
padding-left: 1em;
padding-right: 1em;
text-decoration:none;
}
.sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/
// color: #959595;
background-color: transparent;
font-weight: bold;
}
.sf-menu li {
background-color: transparent;
}
.sf-menu li li {
background: #232323;
text-align: left;
}
.sf-menu li li a {
padding-top: 0.25em;
padding-bottom: 0.25em;
color: #959595;
}
.sf-menu li li li {
background: #232323;
text-align: left;
}
.sf-menu li li li a {
padding-top: 0.25em;
padding-bottom: 0.25em;
color: #959595;
}
.sf-menu li:hover, .sf-menu a:focus, .sf-menu a:active, .sf-menu li.sfHover, .sf-menu a:hover {
color: #FFFFFF;
background-color: #303030;
outline: 0;
}
/*** arrows **/
.sf-menu a.sf-with-ul {
padding-right: 2.25em;
min-width: 1px; /* trigger IE7 hasLayout so spans position accurately */
}
.sf-sub-indicator {
position: absolute;
display: block;
right: .75em;
top: 1.05em; /* IE6 only */
width: 10px;
height: 10px;
text-indent: -999em;
overflow: hidden;
background: url('../images/arrows-ffffff.png') no-repeat -10px -100px; /* 8-bit indexed alpha png. IE6 gets solid image only */
}
a > .sf-sub-indicator { /* give all except IE6 the correct values */
top: .8em;
background-position: 0 -100px; /* use translucent arrow for modern browsers*/
}
/* apply hovers to modern browsers */
a:focus > .sf-sub-indicator,
a:hover > .sf-sub-indicator,
a:active > .sf-sub-indicator,
li:hover > a > .sf-sub-indicator,
li.sfHover > a > .sf-sub-indicator {
background-position: -10px -100px; /* arrow hovers for modern browsers*/
}
/* point right for anchors in subs */
.sf-menu ul .sf-sub-indicator { background-position: -10px 0; }
.sf-menu ul a > .sf-sub-indicator { background-position: 0 0; }
/* apply hovers to modern browsers */
.sf-menu ul a:focus > .sf-sub-indicator,
.sf-menu ul a:hover > .sf-sub-indicator,
.sf-menu ul a:active > .sf-sub-indicator,
.sf-menu ul li:hover > a > .sf-sub-indicator,
.sf-menu ul li.sfHover > a > .sf-sub-indicator {
background-position: -10px 0; /* arrow hovers for modern browsers*/
}
/*** shadows for all but IE6 ***/
.sf-shadow ul {
background: url('../images/shadow.png') no-repeat bottom right;
padding: 0 8px 9px 0;
-moz-border-radius-bottomleft: 17px;
-moz-border-radius-topright: 17px;
-webkit-border-top-right-radius: 17px;
-webkit-border-bottom-left-radius: 17px;
}
.sf-shadow ul.sf-shadow-off {
background: transparent;
}
/** these MUST stay **/
body { margin: 0; padding:0; border: 0; }
a { text-decoration:none}
a:hover {text-decoration: underline}
a.button {text-decoration: none}
h1,h2,h3,h4,h5,h6 {margin: 0.5em 0 0.25em 0; display: block; font-family: Helvetica}
h1 { font-size: 4.00em;}
h2 { font-size: 3.00em;}
h3 { font-size: 2.00em;}
h4 { font-size: 1.50em;}
h5 { font-size: 1.25em;}
h6 { font-size: 1.12em;}
right { float:right; text-align: right; }
left { float:left; text-align: left; }
center { width:100; text-align: center; vertical-align:middle;}
label { white-space: nowrap; }
th, label { font-weight: bold; }
th, td { text-align: left; vertical-align: top; padding: 2px 5px 2px 5px;}
form table tr td label { text-align: left; }
p, table, ol, ul { padding: 0.5em 0 0.5em 0 }
p {text-align: justify }
ol, ul { padding-left: 30px }
li { margin-bottom: 0.5em; }
span, input, select, textarea, button, label, a { display: inline }
img { border: 0; }
blockquote, blockquote p, p blockquote { font-style: italic; margin: 0.5em 30px 0.5em 30px; font-size: 0.9em}
i, em { font-style: italic; }
strong { font-weight: bold; }
small { font-size: 0.8em; }
textarea { width: 600px; }
code { font-family: Courier;}
input[type=text], input[type=password], select { width: 300px; }
ul { list-style-type: none; margin: 0px; padding: 0px; }
/** end **/
/* Sticky footer begin */
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -8em; /* set last value to footer height plus footer vertical padding */
}
.main {
padding: 20px 0 50px 0;
}
.footer, .push {
height: 6em;
padding: 1em 0;
clear: both;
}
.footer-content {position: relative; bottom: -4em; width: 100%;}
.auth_navbar {
white-space: nowrap;
}
/* Sticky footer end */
body {
background-color: #FFFFFF;
}
.footer {
background-color: #ECECEC;
}
.header {
// background: <fill here for header image>;
}
fieldset { padding: 16px; border-top: 1px #DEDEDE solid;}
fieldset legend {text-transform:uppercase; font-weight: bold; padding: 4px 16px 4px 16px; background: #f1f1f1;}
/* fix ie problem with menu */
.ie-lte7 .topbar .container {z-index: 2; }
td.w2p_fw {padding-bottom: 1em;}
td.w2p_fl, td.w2p_fw, td.w2p_fc { vertical-align:top; }
td.w2p_fl { text-align:right; }
td.w2p_fl, td.w2p_fw {padding-right: 7px;}
td.w2p_fl, td.w2p_fc { padding-top: 4px; }
/* tr#submit_record__row {border-top: 1px solid #E5E5E5;} */
#submit_record__row td {padding-top: .5em;}
/* Fix */
#auth_user_remember__row label {display: inline;}
#web2py_user_form td { vertical-align:top; }
a, a:visited, a:hover { color:#0069D6}
/*********** web2py specific ***********/
div.flash {
font-weight: bold;
display: none;
position: fixed;
padding: 10px;
top: 48px;
right: 50px;
min-width: 280px;
opacity: 0.85;
margin: 0px 0px 10px 10px;
color: #fff;
vertical-align: middle;
cursor: pointer;
background: #000;
border: 2px solid #fff;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
z-index: 2;
}
div.error {
background-color: red;
color: white;
padding: 3px;
}
.topbar {
width:100%;
color: #959595; vertical-align:middle;
padding: 0;
background-image: -khtml-gradient(linear, left top, left bottom, from(#333333), to(#222222));
background-image: -moz-linear-gradient(top, #333333, #222222);
background-image: -ms-linear-gradient(top, #333333, #222222);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #333333), color-stop(100%, #222222));
background-image: -webkit-linear-gradient(top, #333333, #222222);
background-image: -o-linear-gradient(top, #333333, #222222);
background-image: linear-gradient(top, #333333, #222222);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);