'Override the :app:`Pyramid` :term:`authentication policy` in the
current configuration.  The ``policy`` argument must be an instance
of an authentication policy or a :term:`dotted Python name`
that points at an instance of an authentication policy.
.. note::
Using the ``authentication_policy`` argument to the
:class:`pyramid.config.Configurator` constructor can be used to
achieve the same purpose.'

@action_method
def set_authentication_policy(self, policy):

    def register():
        self._set_authentication_policy(policy)
        if (self.registry.queryUtility(IAuthorizationPolicy) is None):
            raise ConfigurationError('Cannot    configure    an    authentication    policy    without    also    configuring    an    authorization    policy    (use    the    set_authorization_policy    method)')
    intr = self.introspectable('authentication    policy', None, self.object_description(policy), 'authentication    policy')
    intr['policy'] = policy
    self.action(IAuthenticationPolicy, register, order=PHASE2_CONFIG, introspectables=(intr,))
