swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.59k stars 8.96k forks source link

make oauth popup extensible to support firebase auth via plugin #7698

Open fkowal opened 2 years ago

fkowal commented 2 years ago

https://securetoken.google.com/{MY_PROJECT}/.well-known/openid-configuration

returns this

{
    "issuer": "https://securetoken.google.com/{MY_PROJECT}",
    "jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com",
    "response_types_supported": [
        "id_token"
    ],
    "subject_types_supported": [
        "public"
    ],
    "id_token_signing_alg_values_supported": [
        "RS256"
    ]

}

this is not a full openid configuration that would support the standard oauth flow

to enable custom firebase specific integration

i'd like to add my firebase specifi plugin to integrate with swagger

but to make the possible I need to hook with +- this logic rather than opening the window popup managed by swagger

firebase.initializeApp({...myconfig})

const firestore = firebase.firestore()
const auth = firebase.auth()

const provider = new firebase.auth.GoogleAuthProvider()
auth.signInWithPopup(provider).then(result =>
   result.token -> pass this to swagger
})
inouiw commented 2 years ago

I used the referenced fix to create a wrapActions that wraps the authPopup action. The link to the action:

https://github.com/inouiw/SwaggerUIJsonWebToken/blob/master/wwwroot/swagger-extensions/my-swagger-ui-plugins.js

fkowal commented 2 years ago

Thanks for sharing @inouiw. I'll definitely check it out.