Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The auth_basic() decorator doesn't use functools.wraps(). #586

Closed
GrahamDumpleton opened this issue Feb 12, 2014 · 0 comments
Closed

The auth_basic() decorator doesn't use functools.wraps(). #586

GrahamDumpleton opened this issue Feb 12, 2014 · 0 comments

Comments

@GrahamDumpleton
Copy link

The implementation is:

def auth_basic(check, realm="private", text="Access denied"):
    ''' Callback decorator to require HTTP auth (basic).
        TODO: Add route(check_auth=...) parameter. '''
    def decorator(func):
        def wrapper(*a, **ka):
            user, password = request.auth or (None, None)
            if user is None or not check(user, password):
                err = HTTPError(401, text)
                err.add_header('WWW-Authenticate', 'Basic realm="%s"' % realm)
                return err
            return func(*a, **ka)
        return wrapper
    return decorator

It doesn't use functools.wraps() on the nested wrapper function, which will stuff up name introspection for any functions which the decorator is applied to.

We have seen this affecting data reported by customers applications into New Relic. We are going to change our instrumentation to fix up the bottle code if we see it is wrong, but you should look at fixing it all the same.

alicegoldfuss added a commit to alicegoldfuss/bottle that referenced this issue Feb 12, 2014
defnull added a commit that referenced this issue Feb 12, 2014
defnull pushed a commit that referenced this issue Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant