Forum How do I...?

Authentication path

Tim4c
Hi there,
I didn't find the answer yet. So maybe someone can help.
How can I specify a custom path for the authentication ?
I am looking for something like this :

$prince http://myapp/html/test.pdf -o ~/test.pdf \
--auth-user="myuser@domain.com" \
--auth-password="mypwd" \
--auth-scheme="http" \
--auth-server="myapi.com" \
--auth-path="/api/auth"

Thanks in advance.


wangp
Do you want to only send the credentials when making a HTTP request when the URL contains a particular path? Prince doesn't support that yet.
Tim4c
Thanks for your reply.
I am currently looking for a solution to build a dedicated and private App to generate PDF.
I think, I will develop it with Nuxt Js (Frontend) combined to Strapi(backend).
As everything must be private, Prince needs to be authenticated into Strapi from my frontend app...

I am open to all suggestions to do it.

wangp
If you don't mind sending the credentials with all requests to "myapi.com" (whether it be to "/api/auth" or not) then you can use the HTTP Basic authentication support in Prince.

Otherwise, you could use cookie-based authentication. For example, you could make a login request (outside Prince) to obtain an access token, then tell Prince to send that token as a cookie for any HTTP requests to your backend.
Tim4c
I tried again with the cookie-based authentication, and finally I managed to make it works. My mistake.

I was setting up the cookie like so :
const princeOptions = {
    'cookie': 'jwt=eyJhbGciOiJIUz[...]; domain=localhost;'
}

Prince(princeOptions)
    [...]


instead of :
const princeOptions = {
    'cookies': 'jwt=eyJhbGciOiJIUz[...]; domain=localhost;'
}


Thanks again for your help.