pyeve / eve-swagger

Swagger extension for Eve-powered RESTful APIs
http://python-eve.org
Other
154 stars 43 forks source link

Basic authentication not obeyed #76

Closed checkaayush closed 5 years ago

checkaayush commented 5 years ago

I have added following Flask routes with authentication enabled. Authenticate class is defined appropriately. Basic auth working on all endpoints including /docs but when I access /static/index.html directly, basic auth doesn't work.

What am I missing here?

app = Eve(__name__, static_folder='static', auth=Authenticate)

@app.route('/docs')
@utils.requires_auth
def docs():
    return redirect('/static/index.html', code=301)

@app.route('/')
@utils.requires_auth
def index():
    return send_from_directory('static', 'index.html')
JoveYu commented 5 years ago

because securityDefinitions and security is not implemented, I use this code

SWAGGER_EXT = {
    'securityDefinitions': {
        'basicAuth': {
            'type': 'basic'
        }
    },
    'security': [
        {'basicAuth':[]}
    ],
}
add_documentation(SWAGGER_EXT)
JoveYu commented 5 years ago

the master branch now use swagger3.0, and can auto generate auth docs #86