Coder Social home page Coder Social logo

Comments (2)

infohash avatar infohash commented on June 30, 2024 1

The reason is you don't decorate swagger-ui view function with OIDC and you can't because swagger-ui is provided by the 3rd party package. What you should do is document the authorization of your APIs for Swagger. Swagger-ui has its own authorization implemented and it will obtain the access token from IdP independent of Falsk-pyoidc. You also have to register redirect URI of Swagger in your IdP's client settings.

This is how to document authorization of your APIs for Swagger.

authorizations = {
    'oauth2': {
        'type': 'oauth2',
        'flow': 'accessCode',  # authorizationCode in OpenAPI 3.0
        # 'flow': 'application',  # clientCredentials in OpenAPI 3.0
        # 'flow': 'implicit',
        'authorizationUrl': 'https://idp.example.com/auth,
        'tokenUrl': 'https://idp.example.com/token,
        'clientId': 'client_id123',
        'scopes': {
            'openid': 'Get ID token',
        }
    }
}

Swagger sends access token in the request header so make sure your views are decorated with either @auth.token_auth or @auth.access_control. @auth.oidc_auth is only meant to be used for browser-agents, not for the rest API clients.

@zamzterz You can mark this issue as closed. v3.10 fixed this issue with swagger.

from flask-pyoidc.

zamzterz avatar zamzterz commented on June 30, 2024

I haven't tested this with a SwaggerUI-implementation, so I don't fully understand why it works by loading it in a different tab? Is there some minimal example you could provide to reproduce?

In general though, if no cookies are passed with the request it will unfortunately fail. The session cookie is associated with necessary internal Flask-pyoidc state.

from flask-pyoidc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.