# HG changeset patch # User Martin Bornhold # Date 2016-10-28 12:03:27 # Node ID 91b0b3dbc33e29ce1e16f4cbc36d46a4f968e42c # Parent a6c56473ce7fade8a16aad988fd0e22ff270a643 auth: Allow auth plugins to customize the slug which is used to generate URLs. #4078 diff --git a/rhodecode/authentication/base.py b/rhodecode/authentication/base.py --- a/rhodecode/authentication/base.py +++ b/rhodecode/authentication/base.py @@ -226,6 +226,15 @@ class RhodeCodeAuthPluginBase(object): """ raise NotImplementedError("Not implemented in base class") + def get_url_slug(self): + """ + Returns a slug which should be used when constructing URLs which refer + to this plugin. By default it returns the plugin name. If the name is + not suitable for using it in an URL the plugin should override this + method. + """ + return self.name + @property def is_headers_auth(self): """ diff --git a/rhodecode/authentication/routes.py b/rhodecode/authentication/routes.py --- a/rhodecode/authentication/routes.py +++ b/rhodecode/authentication/routes.py @@ -45,7 +45,7 @@ class AuthnPluginResourceBase(AuthnResou def __init__(self, plugin): self.plugin = plugin - self.__name__ = plugin.name + self.__name__ = plugin.get_url_slug() self.display_name = plugin.get_display_name()