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.0.x core security #9405

Merged
merged 154 commits into from May 2, 2023
Merged

Jetty 12.0.x core security #9405

merged 154 commits into from May 2, 2023

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Feb 22, 2023

This is a core security mechanism, which will ultimately be the base of each of the EEn security handlers.

@gregw
Copy link
Contributor Author

gregw commented Feb 22, 2023

@janbartel @sbordet @lorban I've taken over @lachlan-roberts's core jetty-security work.

This is still draft, but I would really appreciate some early feedback, specially on names and APIs.

The plan is in this PR to get a cleaned up mechanism working with all the common login & identity services, plus the authenticators and authentications. This will be able to be used stand alone.
Only once we are happy with this mechanism as a stand along module, will I then update the eeN modules to actually use it.

Currently it is tested to BASIC auth and data constraints. Best place to start looking is in SecurityHandlerTest

@janbartel yeah I know there is no javadoc. I will write it once the basic API is agreed apon.

@gregw gregw requested a review from janbartel February 22, 2023 06:22
@gregw
Copy link
Contributor Author

gregw commented Feb 24, 2023

Note I have a parallel branch jetty-12.0.x-core-security-ee9, where I am applying this to ee9, very much more a WIP... but it preserves the git history of the moved files.

Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregw perhaps we need to discuss my comments, I'm sure I'm missing important details.

@gregw
Copy link
Contributor Author

gregw commented Feb 27, 2023

@sbordet your comments are mostly clear.

I agree on most of the renamings, however I might delay some until this is merged with eeX implementations, so the refactor will catch them..... or perhaps I won't and we can keep old names in the ee facades over the new names... except for ee10 which will expose the new names. I'll ponder the timing.

Some of your comments are correctly pointing out complications inherited from the original implementation. I'll work to simplify to just what is needed; move to a common ee; or just remove if they really are legacy.

I think I'll change the Constraint to a true Builder pattern as the fluent-like API almost works, but is surprising with regards to naming.

So thanks for the review, it's pointed out more areas that need to be de-legacied and simplified. Lots to do on the plane trip :)

@gregw gregw requested a review from sbordet April 27, 2023 20:15
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more nits/renaming, almost there.

*/
interface AuthConfiguration
{
String getAuthMethod();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump.

Comment on lines +421 to +424
public static void close(Closeable closeable)
{
close((AutoCloseable)closeable);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be able to be, but broke CI big time.
Jenkins is a mystery to me, so simplest to just leave it in:)

@gregw
Copy link
Contributor Author

gregw commented Apr 29, 2023

@sbordet thanks for all the reviews. I have fixed the last round and gone through and resolved the conversations that I think are fixed. There are still a few left (boms, TODOs, etc.) but I think most of those are problems already in HEAD, so I would like to go for a merge and create new issues to fix the TODOs, boms etc. So have a look at the remaining unresolved conversations and see which ones you'd like fixed before merge.

@gregw gregw requested a review from sbordet April 29, 2023 14:36
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregw I need one last rename, and then I'm good: Authorization.Configuration.getAuthMethod() -> getAuthenticationName() or similar, as long as it does not contain abbreviated "auth".

Also, there are now CI failures?

<Arg name="issuer"><Property name="jetty.openid.provider" deprecated="jetty.openid.openIdProvider"/></Arg>
<Arg name="authorizationEndpoint"><Property name="jetty.openid.provider.authorizationEndpoint"/></Arg>
<Arg name="tokenEndpoint"><Property name="jetty.openid.provider.tokenEndpoint"/></Arg>
<Arg name="clientId"><Property name="jetty.openid.clientId"/></Arg>
<Arg name="clientSecret"><Property name="jetty.openid.clientSecret"/></Arg>
<Arg name="authMethod"><Property name="jetty.openid.authMethod" default="client_secret_post"/></Arg>
<Arg name="authenticatorName"><Property name="jetty.openid.authenticatorName" deprecated="jetty.openid.authMethod" default="client_secret_post"/></Arg>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is right.
Elsewhere the authenticatorName is OPENID, while here is client_secret_post.
This should really be the client-side mechanism to use, so it should have a different name.
Perhaps authenticationMethod or clientAuthentication[Method|Mode]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lachlan-roberts HELP!!! what is "client_secret_post" about? Why can the openid authenticator change it's method name?

@sbordet I agree it looks strange.... but it started strange so maybe I open and issue, assign to Lachlan and we move on?

Comment on lines 46 to 47
## What authenticator to use with the Token Endpoint (client_secret_post, client_secret_basic).
# jetty.openid.authenticatorName=client_secret_post
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -50,7 +50,7 @@ public class OpenIdConfiguration extends ContainerLifeCycle
private final String clientId;
private final String clientSecret;
private final List<String> scopes = new ArrayList<>();
private final String authMethod;
private final String authenticatorName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.
This file has numerous occurrences of this to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lachlan-roberts ditto ditto ditto ditto

@@ -11,15 +11,13 @@
// ========================================================================
//

package org.eclipse.jetty.ee9.security.openid;
package org.eclipse.jetty.security.openid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this file to OpenIdRealmNameTest (not the missing l in Ream).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glad you pointed out the missing l. I read it 10 times and thought it was the same :)

public boolean isAuthMandatory()
{
return _map.isAuthMandatory();
return _map.getAuthenticatorName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is never used.
_map.getAuthenticatorName() is only ever used here.
I think we can totally remove the field (and the logic) from MIMap, and that should also allow to remove the delegation by removing MIMap entirely, which in turn fixes the TODO present in the MIMap class (and hopefully also fixes the use of generics for the Map?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the unused method, but for any other jaspi cleanup, I'd prefer to punt that to a new issue/PR. I think there is a lot that needs careful thought about JASPI, so I'd prefer not to delay this PR whilst I page in what the hell JASPI is again and do a clean up.

@sbordet
Copy link
Contributor

sbordet commented May 1, 2023

@gregw just a reminder:

  • Authenticator.getName() -> getAuthenticationType()
  • OpenIdConfiguration.getAuthenticatorName() -> getAuthenticationMethod()

Almost there!

@gregw gregw requested a review from sbordet May 2, 2023 12:39
@gregw gregw merged commit 7275bf1 into jetty-12.0.x May 2, 2023
4 checks passed
@joakime joakime deleted the jetty-12.0.x-core-security branch August 7, 2023 20:15
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

Successfully merging this pull request may close these issues.

Jetty-12 Core security
5 participants