Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
BashkaMen opened this issue Aug 6, 2021 · 7 comments
Open

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

BashkaMen opened this issue Aug 6, 2021 · 7 comments

Comments

@BashkaMen
Copy link

BashkaMen commented Aug 6, 2021

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

BashkaMen commented Aug 6, 2021

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
Copy link
Author

I will try to make a pull request

@BashkaMen
Copy link
Author

can i create pull request?

@Zaid-Ajaj
Copy link
Owner

can i create pull request?

Pull requests are more than welcome! 🙏

@Numpsy
Copy link

Numpsy commented Aug 14, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants