def get_auth(self, username, password, authoritative_source, auth_options=None):
if auth_options is None:<EOL><INDENT>auth_options = {}<EOL><DEDENT>if (authoritative_source is None):<EOL><INDENT>raise AuthError("<STR_LIT>")<EOL><DEDENT>rem = list()<EOL>for key in self._auth_cache:<EOL><INDENT>if self._auth_cache[key]['<STR_LIT>'] < datetime.utcnow():<EOL><INDENT>rem.append(key)<EOL><DEDENT><DEDENT>for key in rem:<EOL><INDENT>del(self._auth_cache[key])<EOL><DEDENT>user_authbackend = username.rsplit('<STR_LIT:@>', <NUM_LIT:1>)<EOL>backend = "<STR_LIT>"<EOL>if len(user_authbackend) == <NUM_LIT:1>:<EOL><INDENT>backend = self._config.get('<STR_LIT>', '<STR_LIT>')<EOL>self._logger.debug("<STR_LIT>" % backend)<EOL><DEDENT>else:<EOL><INDENT>backend = user_authbackend[<NUM_LIT:1>]<EOL><DEDENT>auth_str = ( str(username) + str(password) + str(authoritative_source)<EOL>+ str(auth_options) )<EOL>if auth_str in self._auth_cache:<EOL><INDENT>self._logger.debug('<STR_LIT>' % username)<EOL>return self._auth_cache[auth_str]['<STR_LIT>']<EOL><DEDENT>try:<EOL><INDENT>auth = self._backends[backend](backend, user_authbackend[<NUM_LIT:0>], password, authoritative_source, auth_options)<EOL><DEDENT>except KeyError:<EOL><INDENT>raise AuthError("<STR_LIT>" %<EOL>str(backend))<EOL><DEDENT>self._auth_cache[auth_str] = {<EOL>'<STR_LIT>': datetime.utcnow() + timedelta(seconds=self._config.getint('<STR_LIT>', '<STR_LIT>')),<EOL>'<STR_LIT>': auth<EOL>}<EOL>return auth<EOL>
Returns an authentication object.

            Examines the auth backend given after the '@' in the username and
            returns a suitable instance of a subclass of the BaseAuth class.

            * `username` [string]
                Username to authenticate as.
            * `password` [string]
                Password to authenticate with.
            * `authoritative_source` [string]
                Authoritative source of the query.
            * `auth_options` [dict]
                A dict which, if authenticated as a trusted user, can override
                `username` and `authoritative_source`.