##// END OF EJS Templates
authn: Add whitespace stripping to authentication plugin settings.
johbo -
r55:0ca726bb default
parent child
Show More
@@ -26,6 +26,7 from sqlalchemy.ext.hybrid import hybrid
26 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
26 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
27 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
27 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
28 from rhodecode.authentication.routes import AuthnPluginResourceBase
28 from rhodecode.authentication.routes import AuthnPluginResourceBase
29 from rhodecode.lib.colander_utils import strip_whitespace
29 from rhodecode.lib.utils2 import str2bool, safe_unicode
30 from rhodecode.lib.utils2 import str2bool, safe_unicode
30 from rhodecode.model.db import User
31 from rhodecode.model.db import User
31 from rhodecode.translation import _
32 from rhodecode.translation import _
@@ -52,12 +53,14 class ContainerSettingsSchema(AuthnPlugi
52 colander.String(),
53 colander.String(),
53 default='REMOTE_USER',
54 default='REMOTE_USER',
54 description=_('Header to extract the user from'),
55 description=_('Header to extract the user from'),
56 preparer=strip_whitespace,
55 title=_('Header'),
57 title=_('Header'),
56 widget='string')
58 widget='string')
57 fallback_header = colander.SchemaNode(
59 fallback_header = colander.SchemaNode(
58 colander.String(),
60 colander.String(),
59 default='HTTP_X_FORWARDED_USER',
61 default='HTTP_X_FORWARDED_USER',
60 description=_('Header to extract the user from when main one fails'),
62 description=_('Header to extract the user from when main one fails'),
63 preparer=strip_whitespace,
61 title=_('Fallback header'),
64 title=_('Fallback header'),
62 widget='string')
65 widget='string')
63 clean_username = colander.SchemaNode(
66 clean_username = colander.SchemaNode(
@@ -34,6 +34,7 from sqlalchemy.ext.hybrid import hybrid
34 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
34 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
35 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
35 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
36 from rhodecode.authentication.routes import AuthnPluginResourceBase
36 from rhodecode.authentication.routes import AuthnPluginResourceBase
37 from rhodecode.lib.colander_utils import strip_whitespace
37 from rhodecode.lib.ext_json import json, formatted_json
38 from rhodecode.lib.ext_json import json, formatted_json
38 from rhodecode.model.db import User
39 from rhodecode.model.db import User
39
40
@@ -58,12 +59,14 class CrowdSettingsSchema(AuthnPluginSet
58 colander.String(),
59 colander.String(),
59 default='127.0.0.1',
60 default='127.0.0.1',
60 description=_('The FQDN or IP of the Atlassian CROWD Server'),
61 description=_('The FQDN or IP of the Atlassian CROWD Server'),
62 preparer=strip_whitespace,
61 title=_('Host'),
63 title=_('Host'),
62 widget='string')
64 widget='string')
63 port = colander.SchemaNode(
65 port = colander.SchemaNode(
64 colander.Int(),
66 colander.Int(),
65 default=8095,
67 default=8095,
66 description=_('The Port in use by the Atlassian CROWD Server'),
68 description=_('The Port in use by the Atlassian CROWD Server'),
69 preparer=strip_whitespace,
67 title=_('Port'),
70 title=_('Port'),
68 validator=colander.Range(min=0, max=65536),
71 validator=colander.Range(min=0, max=65536),
69 widget='int')
72 widget='int')
@@ -71,12 +74,14 class CrowdSettingsSchema(AuthnPluginSet
71 colander.String(),
74 colander.String(),
72 default='',
75 default='',
73 description=_('The Application Name to authenticate to CROWD'),
76 description=_('The Application Name to authenticate to CROWD'),
77 preparer=strip_whitespace,
74 title=_('Application Name'),
78 title=_('Application Name'),
75 widget='string')
79 widget='string')
76 app_password = colander.SchemaNode(
80 app_password = colander.SchemaNode(
77 colander.String(),
81 colander.String(),
78 default='',
82 default='',
79 description=_('The password to authenticate to CROWD'),
83 description=_('The password to authenticate to CROWD'),
84 preparer=strip_whitespace,
80 title=_('Application Password'),
85 title=_('Application Password'),
81 widget='password')
86 widget='password')
82 admin_groups = colander.SchemaNode(
87 admin_groups = colander.SchemaNode(
@@ -85,6 +90,7 class CrowdSettingsSchema(AuthnPluginSet
85 description=_('A comma separated list of group names that identify '
90 description=_('A comma separated list of group names that identify '
86 'users as RhodeCode Administrators'),
91 'users as RhodeCode Administrators'),
87 missing='',
92 missing='',
93 preparer=strip_whitespace,
88 title=_('Admin Groups'),
94 title=_('Admin Groups'),
89 widget='string')
95 widget='string')
90
96
@@ -36,6 +36,7 from sqlalchemy.ext.hybrid import hybrid
36 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
36 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
37 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
37 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
38 from rhodecode.authentication.routes import AuthnPluginResourceBase
38 from rhodecode.authentication.routes import AuthnPluginResourceBase
39 from rhodecode.lib.colander_utils import strip_whitespace
39 from rhodecode.lib.utils2 import safe_unicode
40 from rhodecode.lib.utils2 import safe_unicode
40 from rhodecode.model.db import User
41 from rhodecode.model.db import User
41
42
@@ -60,6 +61,7 class JasigCasSettingsSchema(AuthnPlugin
60 colander.String(),
61 colander.String(),
61 default='https://domain.com/cas/v1/tickets',
62 default='https://domain.com/cas/v1/tickets',
62 description=_('The url of the Jasig CAS REST service'),
63 description=_('The url of the Jasig CAS REST service'),
64 preparer=strip_whitespace,
63 title=_('URL'),
65 title=_('URL'),
64 widget='string')
66 widget='string')
65
67
@@ -33,6 +33,7 from sqlalchemy.ext.hybrid import hybrid
33 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
33 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
34 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
34 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
35 from rhodecode.authentication.routes import AuthnPluginResourceBase
35 from rhodecode.authentication.routes import AuthnPluginResourceBase
36 from rhodecode.lib.colander_utils import strip_whitespace
36 from rhodecode.lib.exceptions import (
37 from rhodecode.lib.exceptions import (
37 LdapConnectionError, LdapUsernameError, LdapPasswordError, LdapImportError
38 LdapConnectionError, LdapUsernameError, LdapPasswordError, LdapImportError
38 )
39 )
@@ -71,12 +72,14 class LdapSettingsSchema(AuthnPluginSett
71 colander.String(),
72 colander.String(),
72 default='',
73 default='',
73 description=_('Host of the LDAP Server'),
74 description=_('Host of the LDAP Server'),
75 preparer=strip_whitespace,
74 title=_('LDAP Host'),
76 title=_('LDAP Host'),
75 widget='string')
77 widget='string')
76 port = colander.SchemaNode(
78 port = colander.SchemaNode(
77 colander.Int(),
79 colander.Int(),
78 default=389,
80 default=389,
79 description=_('Port that the LDAP server is listening on'),
81 description=_('Port that the LDAP server is listening on'),
82 preparer=strip_whitespace,
80 title=_('Port'),
83 title=_('Port'),
81 validator=colander.Range(min=0, max=65536),
84 validator=colander.Range(min=0, max=65536),
82 widget='int')
85 widget='int')
@@ -85,6 +88,7 class LdapSettingsSchema(AuthnPluginSett
85 default='',
88 default='',
86 description=_('User to connect to LDAP'),
89 description=_('User to connect to LDAP'),
87 missing='',
90 missing='',
91 preparer=strip_whitespace,
88 title=_('Account'),
92 title=_('Account'),
89 widget='string')
93 widget='string')
90 dn_pass = colander.SchemaNode(
94 dn_pass = colander.SchemaNode(
@@ -92,6 +96,7 class LdapSettingsSchema(AuthnPluginSett
92 default='',
96 default='',
93 description=_('Password to connect to LDAP'),
97 description=_('Password to connect to LDAP'),
94 missing='',
98 missing='',
99 preparer=strip_whitespace,
95 title=_('Password'),
100 title=_('Password'),
96 widget='password')
101 widget='password')
97 tls_kind = colander.SchemaNode(
102 tls_kind = colander.SchemaNode(
@@ -113,6 +118,7 class LdapSettingsSchema(AuthnPluginSett
113 default='',
118 default='',
114 description=_('Base DN to search (e.g., dc=mydomain,dc=com)'),
119 description=_('Base DN to search (e.g., dc=mydomain,dc=com)'),
115 missing='',
120 missing='',
121 preparer=strip_whitespace,
116 title=_('Base DN'),
122 title=_('Base DN'),
117 widget='string')
123 widget='string')
118 filter = colander.SchemaNode(
124 filter = colander.SchemaNode(
@@ -120,6 +126,7 class LdapSettingsSchema(AuthnPluginSett
120 default='',
126 default='',
121 description=_('Filter to narrow results (e.g., ou=Users, etc)'),
127 description=_('Filter to narrow results (e.g., ou=Users, etc)'),
122 missing='',
128 missing='',
129 preparer=strip_whitespace,
123 title=_('LDAP Search Filter'),
130 title=_('LDAP Search Filter'),
124 widget='string')
131 widget='string')
125 search_scope = colander.SchemaNode(
132 search_scope = colander.SchemaNode(
@@ -133,14 +140,16 class LdapSettingsSchema(AuthnPluginSett
133 colander.String(),
140 colander.String(),
134 default='',
141 default='',
135 description=_('LDAP Attribute to map to user name'),
142 description=_('LDAP Attribute to map to user name'),
143 missing_msg=_('The LDAP Login attribute of the CN must be specified'),
144 preparer=strip_whitespace,
136 title=_('Login Attribute'),
145 title=_('Login Attribute'),
137 missing_msg=_('The LDAP Login attribute of the CN must be specified'),
138 widget='string')
146 widget='string')
139 attr_firstname = colander.SchemaNode(
147 attr_firstname = colander.SchemaNode(
140 colander.String(),
148 colander.String(),
141 default='',
149 default='',
142 description=_('LDAP Attribute to map to first name'),
150 description=_('LDAP Attribute to map to first name'),
143 missing='',
151 missing='',
152 preparer=strip_whitespace,
144 title=_('First Name Attribute'),
153 title=_('First Name Attribute'),
145 widget='string')
154 widget='string')
146 attr_lastname = colander.SchemaNode(
155 attr_lastname = colander.SchemaNode(
@@ -148,6 +157,7 class LdapSettingsSchema(AuthnPluginSett
148 default='',
157 default='',
149 description=_('LDAP Attribute to map to last name'),
158 description=_('LDAP Attribute to map to last name'),
150 missing='',
159 missing='',
160 preparer=strip_whitespace,
151 title=_('Last Name Attribute'),
161 title=_('Last Name Attribute'),
152 widget='string')
162 widget='string')
153 attr_email = colander.SchemaNode(
163 attr_email = colander.SchemaNode(
@@ -155,6 +165,7 class LdapSettingsSchema(AuthnPluginSett
155 default='',
165 default='',
156 description=_('LDAP Attribute to map to email address'),
166 description=_('LDAP Attribute to map to email address'),
157 missing='',
167 missing='',
168 preparer=strip_whitespace,
158 title=_('Email Attribute'),
169 title=_('Email Attribute'),
159 widget='string')
170 widget='string')
160
171
@@ -35,6 +35,7 from sqlalchemy.ext.hybrid import hybrid
35 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
35 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
36 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
36 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
37 from rhodecode.authentication.routes import AuthnPluginResourceBase
37 from rhodecode.authentication.routes import AuthnPluginResourceBase
38 from rhodecode.lib.colander_utils import strip_whitespace
38
39
39 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
40
41
@@ -57,6 +58,7 class PamSettingsSchema(AuthnPluginSetti
57 colander.String(),
58 colander.String(),
58 default='login',
59 default='login',
59 description=_('PAM service name to use for authentication.'),
60 description=_('PAM service name to use for authentication.'),
61 preparer=strip_whitespace,
60 title=_('PAM service name'),
62 title=_('PAM service name'),
61 widget='string')
63 widget='string')
62 gecos = colander.SchemaNode(
64 gecos = colander.SchemaNode(
@@ -64,6 +66,7 class PamSettingsSchema(AuthnPluginSetti
64 default='(?P<last_name>.+),\s*(?P<first_name>\w+)',
66 default='(?P<last_name>.+),\s*(?P<first_name>\w+)',
65 description=_('Regular expression for extracting user name/email etc. '
67 description=_('Regular expression for extracting user name/email etc. '
66 'from Unix userinfo.'),
68 'from Unix userinfo.'),
69 preparer=strip_whitespace,
67 title=_('Gecos Regex'),
70 title=_('Gecos Regex'),
68 widget='string')
71 widget='string')
69
72
General Comments 0
You need to be logged in to leave comments. Login now