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
Show file tree
Hide file tree
Changes from 150 commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
9ec946e
initial work on core security module
lachlan-roberts Feb 3, 2023
cde90ab
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
lachlan-roberts Feb 19, 2023
94eca14
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Feb 21, 2023
ab4b3b8
WIP
gregw Feb 22, 2023
dde8780
BASIC auth working
gregw Feb 22, 2023
7ff7d89
FORM auth working
gregw Feb 22, 2023
2db4777
FORM auth working
gregw Feb 22, 2023
5e929d5
FORM auth POST working
gregw Feb 23, 2023
e1de94e
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Feb 23, 2023
63f394c
WIP
gregw Feb 23, 2023
a926bc1
WIP
gregw Feb 23, 2023
87fff1a
WIP
gregw Feb 23, 2023
724141c
WIP
gregw Feb 24, 2023
b34ea8f
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Feb 24, 2023
214a28c
WIP
gregw Feb 24, 2023
e33d076
WIP
gregw Feb 24, 2023
70db469
WIP auth parameters
gregw Feb 25, 2023
13cb316
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Feb 26, 2023
00c81c4
WIP
gregw Feb 28, 2023
3b31f48
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Mar 3, 2023
6216634
WIP
gregw Mar 3, 2023
8044355
WIP
gregw Mar 3, 2023
22fe002
WIP
gregw Mar 4, 2023
804ece1
WIP
gregw Mar 5, 2023
dfb6f2c
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Mar 12, 2023
bc0547d
WIP
gregw Mar 12, 2023
a521f7c
WIP on JAAS tests
gregw Mar 13, 2023
2e4bcd5
WIP on major simplification
gregw Mar 13, 2023
adb84c4
WIP on major simplification
gregw Mar 13, 2023
7a3a2e0
Create OpenID module in jetty-core
lachlan-roberts Mar 30, 2023
447e54b
implement OpenID module for jetty-core
lachlan-roberts Apr 4, 2023
5328138
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Apr 4, 2023
f60a0fb
remove isMandatory and use getConstraintAuthentication method for Aut…
lachlan-roberts Apr 5, 2023
c793052
WIP
gregw Apr 5, 2023
cf9ab28
WIP to using core for EE9
gregw Apr 6, 2023
ce2eee4
WIP to using core for EE9
gregw Apr 7, 2023
468d94a
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Apr 7, 2023
3015c49
WIP to using core for EE9
gregw Apr 7, 2023
e654b3a
WIP to using core for EE9
gregw Apr 7, 2023
071e29b
WIP to using core for EE9
gregw Apr 7, 2023
15455d1
Added core library to modules
gregw Apr 8, 2023
eeae504
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Apr 8, 2023
daa0263
Added core library to modules
gregw Apr 8, 2023
0ef2f50
fixed mod files
gregw Apr 9, 2023
e306c57
fixed ee8 files
gregw Apr 9, 2023
e1034e6
fixed ee8 jaas
gregw Apr 9, 2023
c485ccb
static
gregw Apr 10, 2023
29b44f7
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Apr 10, 2023
7c98514
fixed jaas modules
gregw Apr 10, 2023
43c0870
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Apr 10, 2023
c4cc152
Still fixing ee8 modules
gregw Apr 10, 2023
1407d53
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Apr 10, 2023
eb29894
WIP
gregw Apr 11, 2023
a83d4e5
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Apr 11, 2023
48701d9
fix merge of jetty-12.0.x openid changes
lachlan-roberts Apr 11, 2023
061197d
Update openid to access session
gregw Apr 11, 2023
6023078
WIP
gregw Apr 12, 2023
4aee191
Renamed "Core" environment to "Server"
gregw Apr 12, 2023
67c542d
Merge branch 'jetty-12-server-environment' into jetty-12.0.x-core-sec…
gregw Apr 12, 2023
fff8ef1
fixed jaas
gregw Apr 12, 2023
5cec2c3
more jaas cleanup
gregw Apr 12, 2023
90a547d
Server env exists only in startArgs.
gregw Apr 12, 2023
a4adc62
rename Server env to JVM
gregw Apr 12, 2023
4f48ebf
Merge branch 'jetty-12-server-environment' into jetty-12.0.x-core-sec…
gregw Apr 12, 2023
8f2fcb2
rename of the rename of the rename
gregw Apr 12, 2023
8b3ec42
updates from review
gregw Apr 13, 2023
3da8d52
Merge branch 'jetty-12-server-environment' into jetty-12.0.x-core-sec…
gregw Apr 13, 2023
652eac8
Add new security jar to osgi container deployment
janbartel Apr 13, 2023
763a402
updates from review
gregw Apr 13, 2023
8283cc6
updates from review
gregw Apr 13, 2023
232fb5f
updates from review
gregw Apr 14, 2023
fb093e8
updates from review
gregw Apr 14, 2023
1c436d1
Merge branch 'jetty-12-server-environment' into jetty-12.0.x-core-sec…
gregw Apr 14, 2023
2d2dca7
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Apr 14, 2023
0eab748
ee10 compiled with core security
gregw Apr 14, 2023
1375d72
ee10 compiled with core security
gregw Apr 14, 2023
c12200b
ee10 compiled with core security
gregw Apr 14, 2023
8abcc63
ee10 security tests
gregw Apr 14, 2023
f6ede20
WIP
gregw Apr 17, 2023
01d1637
ee10 security tests
gregw Apr 17, 2023
8ae81a7
ee10 jaspi
gregw Apr 17, 2023
4ce9bef
ee10 jaspi
gregw Apr 17, 2023
60a1975
ee10 jaspi
gregw Apr 17, 2023
50dec68
fix javadoc
gregw Apr 17, 2023
e609a46
WIP
gregw Apr 18, 2023
f669a92
WIP
gregw Apr 18, 2023
0e11e85
WIP on ConstraintTest
gregw Apr 18, 2023
1f25385
WIP on ConstraintTest
gregw Apr 18, 2023
64a52ac
WIP on ConstraintTest
gregw Apr 18, 2023
f73892f
redirection tests
gregw Apr 18, 2023
20f5f64
more FormAuth fixes
gregw Apr 18, 2023
2c9bee2
All ConstraintTests passing ee10
gregw Apr 19, 2023
63b273e
All ConstraintTests passing ee10
gregw Apr 19, 2023
06e5a33
Fixed 302 to 303
gregw Apr 19, 2023
c168947
Refactor to remove forbidden as a separate boolean
gregw Apr 19, 2023
09a645b
Bizarre servlet constraint combinations
gregw Apr 19, 2023
5b6a636
Fixed checkstyle
gregw Apr 19, 2023
02f46b5
Reverted 303 change
gregw Apr 19, 2023
55d564b
Reverted 303 change
gregw Apr 19, 2023
99e5e8c
fixed jaas included
gregw Apr 19, 2023
ec9c7ca
get wrapped request from ServletContextResponse
gregw Apr 19, 2023
5a59314
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Apr 19, 2023
9e9c448
get wrapped request from ServletContextResponse
gregw Apr 19, 2023
f92c851
Add tests for combining of Constraints as per spec
janbartel Apr 19, 2023
6738caf
cherry picked new test from 10
gregw Apr 19, 2023
b424951
turned off debug
gregw Apr 19, 2023
a41594b
fixed auth builder
gregw Apr 20, 2023
34df626
Some renaming after review
gregw Apr 20, 2023
2b4a680
Some renaming after review
gregw Apr 20, 2023
387ed6e
Some renaming after review
gregw Apr 20, 2023
46cf16b
Some renaming after review
gregw Apr 20, 2023
91a9d4c
Really bad SPNEGOAuthenticator tests
gregw Apr 21, 2023
1b926f7
Merged branch 'jetty-12.0.x' into 'jetty-12.0.x-core-security'.
sbordet Apr 23, 2023
59ca19e
Restored HttpClientAuthenticationTest.
sbordet Apr 23, 2023
f32a1d4
Restored SPNEGOAuthenticationTest.
sbordet Apr 23, 2023
d173d72
Fixed checkstyle.
sbordet Apr 23, 2023
5e41571
Fixed RequestListeners (doh!).
sbordet Apr 23, 2023
b1f0af4
remove stack trace
gregw Apr 23, 2023
f36270e
renames for clarity
gregw Apr 23, 2023
0e4eb79
Removed obsolete comment.
sbordet Apr 23, 2023
a8351ed
SPNEGO cleanup
gregw Apr 24, 2023
089d2a6
Updated comment about using the binary `|` operator.
sbordet Apr 24, 2023
8070f4f
More javadoc
gregw Apr 24, 2023
360ba88
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-…
gregw Apr 24, 2023
4a25e88
Cleaned up delegate authentication for openid and SPNEGO
gregw Apr 24, 2023
eb3f72c
Updates from review
gregw Apr 25, 2023
3e11cb8
Updates from review
gregw Apr 25, 2023
2206c00
Updates from review
gregw Apr 25, 2023
010a1dd
Updates from review
gregw Apr 25, 2023
33f6e0b
Fixes from updates from review
gregw Apr 25, 2023
2616604
Fixes from updates from review
gregw Apr 25, 2023
fdc7410
Fixes from updates from review
gregw Apr 25, 2023
835ffc7
Fixes from updates from review
gregw Apr 26, 2023
3f9d35b
Fixes from updates from review
gregw Apr 26, 2023
b00a484
Use INHERIT instead of null for "don't care"
gregw Apr 26, 2023
fa72876
Fixes from updates from review
gregw Apr 26, 2023
deffe0b
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Apr 26, 2023
1bd1808
resovled some TODOs
gregw Apr 27, 2023
a250a39
resolved some TODOs
gregw Apr 27, 2023
81ef12f
Moved some classes to better locations
gregw Apr 27, 2023
7f8ca79
Renamed Authenticator.Configuration
gregw Apr 27, 2023
e95a478
updates from a review
gregw Apr 27, 2023
5b5f3d6
updates from a review
gregw Apr 28, 2023
d5b18bf
Update jetty-core/jetty-security/src/main/java/org/eclipse/jetty/secu…
gregw Apr 29, 2023
8a35ff5
comment usage of MD5
gregw Apr 29, 2023
03c8537
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw Apr 29, 2023
05f7507
removed redundant request field
gregw Apr 29, 2023
37e0d5d
removed redundant response field
gregw Apr 29, 2023
4080c22
updates from a review
gregw Apr 29, 2023
0fb1545
updates from a review
gregw Apr 30, 2023
e5e7322
updates from review
gregw Apr 30, 2023
bc64fc8
Merge branch 'jetty-12.0.x' into jetty-12.0.x-core-security
gregw May 1, 2023
56e5731
updates from review
gregw May 1, 2023
5cbf23b
finish renaming
gregw May 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Expand Up @@ -70,11 +70,11 @@ embedded, via the `jetty.xml` or in a context file for the webapp.

This is what the configuration within a context XML file would look like:

[source, xml, subs="{sub-order}"]
[source,xml,subs="{sub-order}"]
----
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.ConfigurableSpnegoLoginService">
<New class="org.eclipse.jetty.security.SPNEGOLoginService">
<Arg>Test Realm</Arg>
<Arg><Ref refid="authorizationService" /></Arg>
<Set name="keyTabPath"><Ref refid="keyTabPath" /></Set>
Expand Down
Expand Up @@ -56,7 +56,7 @@ See more about the contents of this file in the xref:og-jaas-loginconf[Configuri
[[og-jaas-webapp]]
===== Configure the webapp for JAAS

The `<realm-name>` in `web.xml` will be used to identify the `org.eclipse.jetty.jaas.JAASLoginService` declaration that integrates JAAS with Jetty.
The `<realm-name>` in `web.xml` will be used to identify the `org.eclipse.jetty.security.jaas.JAASLoginService` declaration that integrates JAAS with Jetty.

For example, this `web.xml` contains a realm called `Test JAAS Realm`:

Expand All @@ -71,24 +71,24 @@ For example, this `web.xml` contains a realm called `Test JAAS Realm`:
</form-login-config>
</login-config>
----
<1> The name of the realm, which must be _identical_ to the name of an `org.eclipse.jetty.jaas.JAASLoginService` declaration.
<1> The name of the realm, which must be _identical_ to the name of an `org.eclipse.jetty.security.jaas.JAASLoginService` declaration.

We now need to declare an `org.eclipse.jetty.jaas.JAASLoginService` that references the realm name of `Test JAAS Realm`.
We now need to declare an `org.eclipse.jetty.security.jaas.JAASLoginService` that references the realm name of `Test JAAS Realm`.
Here's an example of a suitable XML snippet:

[source,xml,subs=verbatim]
----
<New class="org.eclipse.jetty.jaas.JAASLoginService">
<New class="org.eclipse.jetty.security.jaas.JAASLoginService">
<Set name="Name">Test JAAS Realm</Set> <!--1-->
<Set name="LoginModuleName">xyz</Set> <!--2-->
</New>
----
<1> The name is the _same_ as that declared in the `<realm-name>` in `web.xml`.
<2> The name that identifies a set of `javax.security.auth.spi.LoginModule` configurations that comprise the xref:og-jaas-loginconf[JAAS config file] identified in the `jetty.jaas.login.conf` property of the xref:og-jaas-module[`jaas` module].

The `org.eclipse.jetty.jaas.JAASLoginService` can be declared in a couple of different places, pick whichever suits your purposes best:
The `org.eclipse.jetty.security.jaas.JAASLoginService` can be declared in a couple of different places, pick whichever suits your purposes best:

* If you have more than one webapp that you would like to use the same security infrastructure, then you can declare your `org.eclipse.jetty.jaas.JAASLoginService` as a bean that is added to the `org.eclipse.jetty.server.Server`.
* If you have more than one webapp that you would like to use the same security infrastructure, then you can declare your `org.eclipse.jetty.security.jaas.JAASLoginService` as a bean that is added to the `org.eclipse.jetty.server.Server`.
The file in which you declare this needs to be on Jetty's execution path.
The recommended procedure is to create a file in your `$jetty.base/etc` directory and then ensure it is on the classpath either by adding it to the Jetty xref:og-start-jar[start command line], or more conveniently to a xref:custom-modules[custom module].
+
Expand All @@ -101,7 +101,7 @@ Here's an example of this type of XML file:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.jaas.JAASLoginService">
<New class="org.eclipse.jetty.security.jaas.JAASLoginService">
<Set name="name">Test JAAS Realm</Set>
<Set name="LoginModuleName">xyz</Set>
</New>
Expand All @@ -110,7 +110,7 @@ Here's an example of this type of XML file:
</Configure>
----

* Alternatively, if you want to use JAAS with a specific webapp only, you declare your `org.eclipse.jetty.jaas.JAASLoginService` in a context XLM file specific to that webapp:
* Alternatively, if you want to use JAAS with a specific webapp only, you declare your `org.eclipse.jetty.security.jaas.JAASLoginService` in a context XLM file specific to that webapp:
+
[source,xml]
----
Expand All @@ -120,7 +120,7 @@ Here's an example of this type of XML file:
<Set name="securityHandler">
<New class="org.eclipse.jetty.security.ConstraintSecurityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.jaas.JAASLoginService">
<New class="org.eclipse.jetty.security.jaas.JAASLoginService">
<Set name="name">Test JAAS Realm</Set>
<Set name="loginModuleName">xyz</Set>
</New>
Expand All @@ -145,7 +145,7 @@ xyz { <1>
com.other.OtherLoginModule optional; <3>
};
----
<1> The name of the configuration _exactly_ as specified in your `org.eclipse.jetty.jaas.JAASLoginService` declaration.
<1> The name of the configuration _exactly_ as specified in your `org.eclipse.jetty.security.jaas.JAASLoginService` declaration.
<2> The first `LoginModule` declaration, containing the classname of the `LoginModule` and its configuration properties.
<3> A second `LoginModule` declaration.
You can provide as many `LoginModule` alternatives as you like, with a minimum of one.
Expand All @@ -154,10 +154,10 @@ Refer to the link:https://docs.oracle.com/javase/7/docs/api/javax/security/auth/
[[og-jaas-loginmodules]]
==== Provided LoginModules

* link:{javadoc-url}/org/eclipse/jetty/jaas/spi/JDBCLoginModule.html[`org.eclipse.jetty.jaas.spi.JDBCLoginModule`]
* link:{javadoc-url}/org/eclipse/jetty/jaas/spi/PropertyFileLoginModule.html[`org.eclipse.jetty.jaas.spi.PropertyFileLoginModule`]
* link:{javadoc-url}/org/eclipse/jetty/jaas/spi/DataSourceLoginModule.html[`org.eclipse.jetty.jaas.spi.DataSourceLoginModule`]
* link:{javadoc-url}/org/eclipse/jetty/jaas/spi/LdapLoginModule.html[`org.eclipse.jetty.jaas.ldap.LdapLoginModule`]
* link:{javadoc-url}/org/eclipse/jetty/security/jaas/spi/JDBCLoginModule.html[`org.eclipse.jetty.security.jaas.spi.JDBCLoginModule`]
* link:{javadoc-url}/org/eclipse/jetty/security/jaas/spi/PropertyFileLoginModule.html[`org.eclipse.jetty.security.jaas.spi.PropertyFileLoginModule`]
* link:{javadoc-url}/org/eclipse/jetty/security/jaas/spi/DataSourceLoginModule.html[`org.eclipse.jetty.security.jaas.spi.DataSourceLoginModule`]
* link:{javadoc-url}/org/eclipse/jetty/security/jaas/spi/LdapLoginModule.html[`org.eclipse.jetty.security.jaas.ldap.LdapLoginModule`]

[NOTE]
====
Expand All @@ -167,15 +167,15 @@ The class link:{javadoc-url}/org/eclipse/jetty/util/security/Password.html[`org.

===== JDBCLoginModule

The `org.eclipse.jetty.jaas.spi.JDBCLoginModule` stores user passwords and roles in a database accessed via JDBC calls.
The `org.eclipse.jetty.security.jaas.spi.JDBCLoginModule` stores user passwords and roles in a database accessed via JDBC calls.
You can configure the JDBC connection information, as well as the names of the table and columns storing the username and credential, and the names of the table and columns storing the roles.

Here is an example xref:og-jaas-loginconf[login module configuration file] entry for it using an HSQLDB driver:

[source,subs=verbatim]
----
jdbc { <1>
org.eclipse.jetty.jaas.spi.JDBCLoginModule required <2><3>
org.eclipse.jetty.security.jaas.spi.JDBCLoginModule required <2><3>
dbUrl="jdbc:hsqldb:." <4>
dbUserName="sa" <5>
dbDriver="org.hsqldb.jdbcDriver" <6>
Expand Down Expand Up @@ -216,15 +216,15 @@ Note that passwords can be stored in the database in plain text or encoded forma

===== DataSourceLoginModule

Similar to the `org.eclipse.jetty.jaas.spi.JDBCLoginModule`, but using a `javax.sql.DataSource` to connect to the database instead of a JDBC driver.
Similar to the `org.eclipse.jetty.security.jaas.spi.JDBCLoginModule`, but using a `javax.sql.DataSource` to connect to the database instead of a JDBC driver.
The `javax.sql.DataSource` is obtained at runtime by performing a JNDI lookup on `java:comp/env/${dnJNDIName}`.

A sample login module configuration for this `LoginModule`:

[source,subs=verbatim]
----
ds { <1>
org.eclipse.jetty.jaas.spi.DataSourceLoginModule required <2><3>
org.eclipse.jetty.security.jaas.spi.DataSourceLoginModule required <2><3>
dbJNDIName="ds" <4>
userTable="myusers" <5>
userField="myuser" <6>
Expand Down Expand Up @@ -252,7 +252,7 @@ With this login module implementation, the authentication and role information i
[source,subs=verbatim]
----
props { <1>
org.eclipse.jetty.jaas.spi.PropertyFileLoginModule required <2><3>
org.eclipse.jetty.security.jaas.spi.PropertyFileLoginModule required <2><3>
file="/somewhere/somefile.props"; <4>
};
----
Expand Down Expand Up @@ -281,15 +281,15 @@ The contents of the file are fully read in and cached in memory the first time a

===== LdapLoginModule

The `org.eclipse.jetty.jaas.spi.LdapLoginModule` uses LDAP to access authentication and authorization information stored in a directory.
The `org.eclipse.jetty.security.jaas.spi.LdapLoginModule` uses LDAP to access authentication and authorization information stored in a directory.
The LDAP connection information and structure of the authentication/authorization data can be configured.

Here's an example:

[source,subs=verbatim]
----
example { <1>
org.eclipse.jetty.jaas.spi.LdapLoginModule required <2><3>
org.eclipse.jetty.security.jaas.spi.LdapLoginModule required <2><3>
contextFactory="com.sun.jndi.ldap.LdapCtxFactory" <4>
hostname="ldap.example.com" <5>
port="389" <6>
Expand Down