Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
272 stars 54 forks source link

How to get around authorization in path to docs?? #263

Open BashkaMen opened 3 years ago

BashkaMen commented 3 years ago

Hello, it is my app

let webApp = choose [
    AuthRemoting.webApp
    requiresAuthentication (setStatusCode 403 >=> text "need auth") >=> ClientRemoting.webApp
]

both remoting has docs, but i can open docs only for AuthRemoting maybe i can create docs page as separate api?

Zaid-Ajaj commented 3 years ago

Hi @BashkaMen thanks for filing the issue! It seems like we haven't accounted for this use case 🤔 I need to think about it because even if you expose the docs as a separate API, clients won't be able to call the docs functions unless you are authenticated too

Zaid-Ajaj commented 3 years ago

Do you have any suggestions on how to go about this? We could add an additional text field in the generated docs to specify the authorization header or cookie. Maybe that could work 🤔

BashkaMen commented 3 years ago
let apiDocs =
        let docs = Docs.createFor<Api>()
        Remoting.documentation "Client api" [
            docs.route <@ fun api -> api.GetInfo @>
            |> docs.alias "Get client info"
            |> docs.example <@ fun api -> api.GetInfo @>
            |> docs.example <@ fun api -> api.GetInfo @>
            |> docs.withHeaders "Authorization" "Bearer Token"
        ]

this would be enough for me

BashkaMen commented 3 years ago

I will try to make a pull request

BashkaMen commented 3 years ago

can i create pull request?

Zaid-Ajaj commented 3 years ago

can i create pull request?

Pull requests are more than welcome! 🙏

Numpsy commented 3 years ago

We could add an additional text field in the generated docs to specify the authorization header or cookie. Maybe that could work 🤔

fwiw, that's sort of what SwaggerUI allows -

image

I used it in a project at work once that required a type of licence to be passed in order to be able to call the functions, and that lets you enter the key once and then call multiple other functions without needing it seperately