miguelgrinberg / APIFairy

A minimalistic API framework built on top of Flask, Marshmallow and friends.
MIT License
323 stars 30 forks source link

Add authentication to docs #66

Closed hackzaid closed 1 year ago

hackzaid commented 2 years ago

I would like to add login to the apifairy.docs so that only allowed/logged on users can access the documentation for my API.

I had tried adding @login_required on

@app.route('/') 
@login_required 
    def index():
        return redirect(url_for('apifairy.docs'))

but this couldn't find the set url on the login.login_view = "dev_auth.login"

What could be a better away to achive this as this is my first major API project and can't seem to find a work around

miguelgrinberg commented 2 years ago

APIFairy is designed to work on APIs, not on web applications. I don't plan to support standard cookie-based logins. Authentication with Flask-HTTPAuth is fully supported though, see the @authenticate decorator in the docs.