formio.js icon indicating copy to clipboard operation
formio.js copied to clipboard

File upload component and access token

Open aminmc opened this issue 7 years ago • 9 comments

Hello

We have a file component configured to use a custom URL. The custom URL is protected with Keycloak. Is there a way to pass a bearer token as "Authorization" header?

Thanks

aminmc avatar Mar 21 '19 10:03 aminmc

We are passing along the jwt token which might help. You can see the code here: https://github.com/formio/formio.js/blob/master/src/providers/storage/url.js#L60-L63

randallknutson avatar Mar 21 '19 14:03 randallknutson

@randallknutson We need to pass the bearer token of the user rather than the one from form io. The access token will be short lived.

aminmc avatar Mar 21 '19 14:03 aminmc

We don't currently have a way of passing a Bearer token to the file handler. Is that something you would like to add?

randallknutson avatar Mar 21 '19 20:03 randallknutson

@randallknutson I think it would be good to be able to pass the token along. I'll take a look at a solution and run it past you.

aminmc avatar Mar 22 '19 12:03 aminmc

Sounds good. Let us know.

randallknutson avatar Mar 22 '19 14:03 randallknutson

@aminmc Did you find any solution for this problem?

Dhruvv4 avatar Sep 23 '19 10:09 Dhruvv4

@Dhruvv4 Yup..Basically we create our own file service and pass that into the formio service. The 3methods upload, download and delete get a token passed through in our implementation.

aminmc avatar Sep 23 '19 10:09 aminmc

this can now be done using FileService and injecting it into the options for formio.

aminmc avatar Sep 25 '19 05:09 aminmc

Can you provide an example?

Thanks

Dhruvv4 avatar Sep 25 '19 11:09 Dhruvv4