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

Disable service authentication #82

Open
fabrii opened this issue Feb 9, 2021 · 4 comments
Open

Disable service authentication #82

fabrii opened this issue Feb 9, 2021 · 4 comments

Comments

@fabrii
Copy link

fabrii commented Feb 9, 2021

It seems that the credentials file is mandatory. If we don't provide one, the application cannot start.

In my case, I am using Google Storage to persist files. In some dev environments I want to save the files directly to the filesystem without providing a ".json" file with credentials.

Is there any way of doing this?

Thanks!

@fabrii fabrii changed the title Disable service option Disable service authentication Feb 9, 2021
@loicmathieu
Copy link
Collaborator

It's a little more complexe, see https://github.com/quarkiverse/quarkus-google-cloud-services#authenticating-to-google-cloud

Your issue is that you want to use Storage in some env and something else on other env.
And as soon as you add the storage dependency, a Storage CDI bean is produced that mandates the authentication.

The issue is that somewhere inside your code you inject the Storage bean, and this triggers the auth.

To workaround this, you can provide an alternative bean that mock the Storage bean and will be injected instead of the real one.

Another solution would be to have a CDI producer that will conditionaly produce a StorageFileService or a LocalFileService based on a config property. The StorageFileService would wrap the Storage object so that if not produced, the Storage bean will not be initialized as not injected anywhere.

@loicmathieu
Copy link
Collaborator

@fabrii do you successfully workaround the issue with my explaintations ? Can I close this issue now ?

@fabrii
Copy link
Author

fabrii commented May 17, 2021

Hi @loicmathieu.

I couldn't workaround the issue.
What I had in mind when reporting the issue was creating a property similar like this:

quarkus.google.cloud.enabled=false (optional, true by default)

And use that property internally to disable the initialization of the component.

If this approach is not correct, you can close the issue.

Thanks!

@fabrii
Copy link
Author

fabrii commented Feb 12, 2022

We managed to solve it in an easier way. We moved the @Inject Storage to a @RequestScoped bean.
That bean is only created when the methods are invoked, so no Storage automatic initialization.

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

2 participants