vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
895 stars 56 forks source link

Make it easier to enable authentication when using File Router #2311

Open cromoteca opened 5 months ago

cromoteca commented 5 months ago

Describe your motivation

Hilla now generates many files automatically when using file router. Some of them need to be replaced with custom versions just to enable authentication, which is a need in almost all applications. That means giving up on automatic versions of those files.

At least index.tsx and routes.tsx need to be customized, and auth.ts added.

Describe the solution you'd like

The generated files already contain support for authentication and nothing happens if authentication is not used.

Describe alternatives you've considered

No response

Additional context

But not everything can be set up automatically, as the developer still needs to provide the endpoint used to get user information, so he has to create an auth.ts file manually, as per documentation.

cromoteca commented 5 months ago

As discussed internally, we could use a Java interface to be implemented in an endpoint and, if that interface is found, that could trigger authentication support and could allow to generate all needed files, including auth.ts.