Skip to content

Support mixing the use of auth objects and external auth library #293

@greyli

Description

@greyli

Example usage from a user:

from apiflask import APIFlask, HTTPTokenAuth


# API Key
apikey = HTTPTokenAuth(scheme='ApiKey', header='X-API-Key')
apikeys = {"123": "123",
           "456":"456"}

@apikey.verify_token
def verify_apikey(apikey):
    if apikey in apikeys:
        return apikeys[apikey]


app = APIFlask(__name__)

# Outh2
app.security_schemes = {
'OpenID': {
  'type': 'openIdConnect',
  'openIdConnectUrl': 'https://login.microsoftonline.com/68ff8/v2.0/.well-known/openid-configuration'
}
}

@app.get('/outh2test')
@app.doc(security='OAuth2')
def ouath2test():
    print ("hello")


@app.get('/apikeytest')
@app.auth_required(apikey)
def apikeytest():
    print ("hello")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions