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

Jetty 12: instantiation of HashLoginService #10068

Closed
zUniQueX opened this issue Jul 5, 2023 · 4 comments
Closed

Jetty 12: instantiation of HashLoginService #10068

zUniQueX opened this issue Jul 5, 2023 · 4 comments
Assignees

Comments

@zUniQueX
Copy link
Contributor

zUniQueX commented Jul 5, 2023

Jetty version(s)
12.0.0.beta2

Description
Hey Jetty team. The beta versions of Jetty 12 work well so far. However, while trying to upgrade from 11, I've experienced a problem with instantiation in a Maven integration test.

When using the Maven plugin for Jetty 11, the config property of the HashLoginService was a String and could be set via the Maven configuration directly as described in the docs. In Jetty 12 the config is now an instance of Resource. Since no implementation of Resource provides a no-arg constructor, the existing implementations cannot be used in the Maven configuration.

Maybe we could add a utility module with classes supporting Maven configurations to solve the instantiation problem without changing the current resource semantics.

@gregw
Copy link
Contributor

gregw commented Jul 5, 2023

In our XML configuration we can create Resource instance with something like:

    <Call id="ResourceFactory" class="org.eclipse.jetty.util.resource.ResourceFactory" name="of">
       <Arg><Ref refid="Server" /></Arg>
       <Call id="realmResource" name="newResource"
         <Arg><Property name="login.realm" default="src/test/resources/realm.properties"/></Arg>
       </Call>
    </Call>

But I'm guessing that maven cannot do something like that? @janbartel does maven have any other way to create instances to pass to methods that we can support via some static API?

@janbartel
Copy link
Contributor

@zUniQueX yes, Resource was completely reworked in jetty-12 and the interfaces of a lot of classes that used resources internally.

Pondering what we could do about this. Ideally in any solution we would tie the ResourceFactory to the Server instance, however at the time of plugin configuration, the Server instance does not exist. We might be able to do something with a URLResourceFactory instead.

Anyway, while we ponder this, I just wanted to bring to your attention that it has always been possible to define a jetty.xml file in which you can configure the Server or any container-level jetty object, including a HashLogin service. That would allow you to call the new Resource code as per Greg's snippet posted above for jetty-12 (you could also convert your plugin configurations of older versions of jetty to do the same thing). Or if this is a context-specific object, you can define a context.xml file instead.

@janbartel
Copy link
Contributor

@zUniQueX I think PR #10077 should address your concerns.

You would use it like this:

          <configuration>
              <loginServices>
                  <loginService implementation="org.eclipse.jetty.security.HashLoginService">
                      <config implementation="org.eclipse.jetty.ee10.maven.plugin.MavenResource">
                          <resourceAsString>${basedir}/src/config/login.xml</resourceAsString>
                      </config>
                  </loginService>
              </loginServices>
          </configuration>

@zUniQueX
Copy link
Contributor Author

zUniQueX commented Jul 7, 2023

Looks very good. Thanks for the fast implementation 👍

@zUniQueX zUniQueX closed this as completed Jul 7, 2023
@gregw gregw moved this to ✅ Done in Jetty 12.0.0.beta4 Jul 10, 2023
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

3 participants