How to require login for Keycloak RealmResourceProvider

I currently have a RealmResourceProvider for my realm “test”. Its URL is http://localhost:8080/auth/realms/test/domainextension. I want the user to be authenticated in the realm in order to access this page. However, right now anyone can access this page, even if not authenticated. Is there some kind of magic function like :


Or any kind of annotation like @Secured ?
I want the user to be redirected to the realm authentication form, and then to the RealmResourceProvider URL when logged in.