authn: Add whitespace stripping to authentication plugin settings.
This commit is contained in:
parent
69bf06bfcc
commit
6713b054ef
5 changed files with 26 additions and 1 deletions
|
|
@ -26,6 +26,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
|
||||
from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
|
||||
from rhodecode.authentication.routes import AuthnPluginResourceBase
|
||||
from rhodecode.lib.colander_utils import strip_whitespace
|
||||
from rhodecode.lib.utils2 import str2bool, safe_unicode
|
||||
from rhodecode.model.db import User
|
||||
from rhodecode.translation import _
|
||||
|
|
@ -52,12 +53,14 @@ class ContainerSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
colander.String(),
|
||||
default='REMOTE_USER',
|
||||
description=_('Header to extract the user from'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Header'),
|
||||
widget='string')
|
||||
fallback_header = colander.SchemaNode(
|
||||
colander.String(),
|
||||
default='HTTP_X_FORWARDED_USER',
|
||||
description=_('Header to extract the user from when main one fails'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Fallback header'),
|
||||
widget='string')
|
||||
clean_username = colander.SchemaNode(
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
|
||||
from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
|
||||
from rhodecode.authentication.routes import AuthnPluginResourceBase
|
||||
from rhodecode.lib.colander_utils import strip_whitespace
|
||||
from rhodecode.lib.ext_json import json, formatted_json
|
||||
from rhodecode.model.db import User
|
||||
|
||||
|
|
@ -58,12 +59,14 @@ class CrowdSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
colander.String(),
|
||||
default='127.0.0.1',
|
||||
description=_('The FQDN or IP of the Atlassian CROWD Server'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Host'),
|
||||
widget='string')
|
||||
port = colander.SchemaNode(
|
||||
colander.Int(),
|
||||
default=8095,
|
||||
description=_('The Port in use by the Atlassian CROWD Server'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Port'),
|
||||
validator=colander.Range(min=0, max=65536),
|
||||
widget='int')
|
||||
|
|
@ -71,12 +74,14 @@ class CrowdSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
colander.String(),
|
||||
default='',
|
||||
description=_('The Application Name to authenticate to CROWD'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Application Name'),
|
||||
widget='string')
|
||||
app_password = colander.SchemaNode(
|
||||
colander.String(),
|
||||
default='',
|
||||
description=_('The password to authenticate to CROWD'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Application Password'),
|
||||
widget='password')
|
||||
admin_groups = colander.SchemaNode(
|
||||
|
|
@ -85,6 +90,7 @@ class CrowdSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
description=_('A comma separated list of group names that identify '
|
||||
'users as RhodeCode Administrators'),
|
||||
missing='',
|
||||
preparer=strip_whitespace,
|
||||
title=_('Admin Groups'),
|
||||
widget='string')
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
|
||||
from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
|
||||
from rhodecode.authentication.routes import AuthnPluginResourceBase
|
||||
from rhodecode.lib.colander_utils import strip_whitespace
|
||||
from rhodecode.lib.utils2 import safe_unicode
|
||||
from rhodecode.model.db import User
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ class JasigCasSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
colander.String(),
|
||||
default='https://domain.com/cas/v1/tickets',
|
||||
description=_('The url of the Jasig CAS REST service'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('URL'),
|
||||
widget='string')
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
|
||||
from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
|
||||
from rhodecode.authentication.routes import AuthnPluginResourceBase
|
||||
from rhodecode.lib.colander_utils import strip_whitespace
|
||||
from rhodecode.lib.exceptions import (
|
||||
LdapConnectionError, LdapUsernameError, LdapPasswordError, LdapImportError
|
||||
)
|
||||
|
|
@ -71,12 +72,14 @@ class LdapSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
colander.String(),
|
||||
default='',
|
||||
description=_('Host of the LDAP Server'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('LDAP Host'),
|
||||
widget='string')
|
||||
port = colander.SchemaNode(
|
||||
colander.Int(),
|
||||
default=389,
|
||||
description=_('Port that the LDAP server is listening on'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Port'),
|
||||
validator=colander.Range(min=0, max=65536),
|
||||
widget='int')
|
||||
|
|
@ -85,6 +88,7 @@ class LdapSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
default='',
|
||||
description=_('User to connect to LDAP'),
|
||||
missing='',
|
||||
preparer=strip_whitespace,
|
||||
title=_('Account'),
|
||||
widget='string')
|
||||
dn_pass = colander.SchemaNode(
|
||||
|
|
@ -92,6 +96,7 @@ class LdapSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
default='',
|
||||
description=_('Password to connect to LDAP'),
|
||||
missing='',
|
||||
preparer=strip_whitespace,
|
||||
title=_('Password'),
|
||||
widget='password')
|
||||
tls_kind = colander.SchemaNode(
|
||||
|
|
@ -113,6 +118,7 @@ class LdapSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
default='',
|
||||
description=_('Base DN to search (e.g., dc=mydomain,dc=com)'),
|
||||
missing='',
|
||||
preparer=strip_whitespace,
|
||||
title=_('Base DN'),
|
||||
widget='string')
|
||||
filter = colander.SchemaNode(
|
||||
|
|
@ -120,6 +126,7 @@ class LdapSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
default='',
|
||||
description=_('Filter to narrow results (e.g., ou=Users, etc)'),
|
||||
missing='',
|
||||
preparer=strip_whitespace,
|
||||
title=_('LDAP Search Filter'),
|
||||
widget='string')
|
||||
search_scope = colander.SchemaNode(
|
||||
|
|
@ -133,14 +140,16 @@ class LdapSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
colander.String(),
|
||||
default='',
|
||||
description=_('LDAP Attribute to map to user name'),
|
||||
title=_('Login Attribute'),
|
||||
missing_msg=_('The LDAP Login attribute of the CN must be specified'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Login Attribute'),
|
||||
widget='string')
|
||||
attr_firstname = colander.SchemaNode(
|
||||
colander.String(),
|
||||
default='',
|
||||
description=_('LDAP Attribute to map to first name'),
|
||||
missing='',
|
||||
preparer=strip_whitespace,
|
||||
title=_('First Name Attribute'),
|
||||
widget='string')
|
||||
attr_lastname = colander.SchemaNode(
|
||||
|
|
@ -148,6 +157,7 @@ class LdapSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
default='',
|
||||
description=_('LDAP Attribute to map to last name'),
|
||||
missing='',
|
||||
preparer=strip_whitespace,
|
||||
title=_('Last Name Attribute'),
|
||||
widget='string')
|
||||
attr_email = colander.SchemaNode(
|
||||
|
|
@ -155,6 +165,7 @@ class LdapSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
default='',
|
||||
description=_('LDAP Attribute to map to email address'),
|
||||
missing='',
|
||||
preparer=strip_whitespace,
|
||||
title=_('Email Attribute'),
|
||||
widget='string')
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
|
||||
from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
|
||||
from rhodecode.authentication.routes import AuthnPluginResourceBase
|
||||
from rhodecode.lib.colander_utils import strip_whitespace
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -57,6 +58,7 @@ class PamSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
colander.String(),
|
||||
default='login',
|
||||
description=_('PAM service name to use for authentication.'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('PAM service name'),
|
||||
widget='string')
|
||||
gecos = colander.SchemaNode(
|
||||
|
|
@ -64,6 +66,7 @@ class PamSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
default='(?P<last_name>.+),\s*(?P<first_name>\w+)',
|
||||
description=_('Regular expression for extracting user name/email etc. '
|
||||
'from Unix userinfo.'),
|
||||
preparer=strip_whitespace,
|
||||
title=_('Gecos Regex'),
|
||||
widget='string')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue