You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since headscale currently has no WebUI, it would be a quality of life feature to enable using the Swagger UI directly in the web browser without installing an add-on. (For what I've seen so far, a relatively small change)
Even though the documentation for version 2.0 does not mention bearer tokens for authentication, it is still usable if type: apikey together with name: Authorization is used in the securityDefinitions. With this configuration, an admin can brows /swagger, press Authorize and provide the value "Bearer " followed by the effective token.
What I've tried by myself
I think I know what changes have to be made to the .swagger.json files to enable this feature. I've a locally development build version running (in a container) and as far as I can see it works, with:
{
"swagger": "2.0",
"info": {
"title": "headscale/v1/headscale.proto",
"version": "version not set"
},
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
"name": "Authorization",
"in": "header",
"description": "Bearer token for authentication. Please type in 'Bearer' followed by a space and then the token."
}
},
"security": [
{
"Bearer": ["read", "write"]
}
],
// followed by the rest of the generated .swagger.json file
in /gen/openapiv2/headscale/v1/headscale.swagger.json.
But I do currently not know, what kind of changes I've to make, so that the next make generate command won't overwrite the files.
The text was updated successfully, but these errors were encountered:
SwissGipfel
changed the title
Use Authorization in Swagger UI with SecuirtyDefinition in .swagger.json
Use Authorization in Swagger UI with SecurityDefinition in .swagger.json
Jan 9, 2024
Why
Since headscale currently has no WebUI, it would be a quality of life feature to enable using the Swagger UI directly in the web browser without installing an add-on. (For what I've seen so far, a relatively small change)
Description
Swagger 2.0 lets you define an authentication type for each API endpoint. This definition will also be displayed in swagger UI and is usable as such. With it an admin can leverage the APIs listed on the
/swagger
endpoint directly without using cli tools or browser add-on.Even though the documentation for version 2.0 does not mention bearer tokens for authentication, it is still usable if
type: apikey
together withname: Authorization
is used in the securityDefinitions. With this configuration, an admin can brows/swagger
, press Authorize and provide the value "Bearer " followed by the effective token.What I've tried by myself
I think I know what changes have to be made to the
.swagger.json
files to enable this feature. I've a locally development build version running (in a container) and as far as I can see it works, with:in
/gen/openapiv2/headscale/v1/headscale.swagger.json
.But I do currently not know, what kind of changes I've to make, so that the next
make generate
command won't overwrite the files.The text was updated successfully, but these errors were encountered: