Skip to content

Commit d0ff2b9

Browse files
committed
SOLR-17845: Implement OAuth support in new UI (#3754)
This merge adds support for OAuth in the new UI by using a Ktor server for handling callbacks to the app on desktop, and new tab and event listeners on Web. The solution also adds support for multiple authentication options (MultiAuthPlugin), but with solr-server side limitations. (cherry picked from commit d065313)
1 parent f5a33b6 commit d0ff2b9

File tree

48 files changed

+2219
-57
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2219
-57
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title: SOLR 17845 - Implement OAuth support in new UI
2+
type: added
3+
authors:
4+
- name: Christos Malliaridis
5+
nick: malliaridis
6+
url: https://home.apache.org/phonebook.html?uid=malliaridis
7+
links:
8+
- name: SOLR-17845
9+
url: https://issues.apache.org/jira/browse/SOLR-17845

gradle/libs.versions.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ spatial4j = "0.8"
197197
spotbugs = "4.9.6"
198198
squareup-okhttp3-mockwebserver = "4.12.0"
199199
squareup-okhttp3-okhttp = "4.12.0"
200+
squareup-okio = "3.16.0"
200201
stephenc-jcip = "1.0-1"
201202
swagger3 = "2.2.22"
202203
tdunning-tdigest = "3.3"
@@ -446,6 +447,9 @@ ktor-client-contentNegotiation = { module = "io.ktor:ktor-client-content-negotia
446447
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
447448
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
448449
ktor-client-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
450+
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
451+
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
452+
ktor-server-htmlBuilder = { module = "io.ktor:ktor-server-html-builder", version.ref = "ktor" }
449453
langchain4j-bom = { module = "dev.langchain4j:langchain4j-bom", version.ref = "langchain4j-bom" }
450454
langchain4j-cohere = { module = "dev.langchain4j:langchain4j-cohere" }
451455
langchain4j-core = { module = "dev.langchain4j:langchain4j-core" }
@@ -509,6 +513,7 @@ slf4j-jultoslf4j = { module = "org.slf4j:jul-to-slf4j", version.ref = "slf4j" }
509513
spotbugs-annotations = { module = "com.github.spotbugs:spotbugs-annotations", version.ref = "spotbugs" }
510514
squareup-okhttp3-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "squareup-okhttp3-mockwebserver" }
511515
squareup-okhttp3-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "squareup-okhttp3-okhttp" }
516+
squareup-okio = { module = "com.squareup.okio:okio", version.ref = "squareup-okio" }
512517
stephenc-jcip-annotations = { module = "com.github.stephenc.jcip:jcip-annotations", version.ref = "stephenc-jcip" }
513518
swagger3-annotations-jakarta = { module = "io.swagger.core.v3:swagger-annotations-jakarta", version.ref = "swagger3" }
514519
swagger3-jaxrs2-jakarta = { module = "io.swagger.core.v3:swagger-jaxrs2-jakarta", version.ref = "swagger3" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
60375cdf2fd0ed2a1dcd6db787095f732a31ff10

solr/licenses/okio-jvm-3.6.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

solr/modules/jwt-auth/gradle.lockfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ com.nimbusds:nimbus-jose-jwt:10.5=jarValidation,testCompileClasspath,testRuntime
3737
com.nimbusds:oauth2-oidc-sdk:10.10.1=jarValidation,testCompileClasspath,testRuntimeClasspath
3838
com.squareup.okhttp3:mockwebserver:4.12.0=jarValidation,testCompileClasspath,testRuntimeClasspath
3939
com.squareup.okhttp3:okhttp:4.12.0=jarValidation,testCompileClasspath,testRuntimeClasspath
40-
com.squareup.okio:okio-jvm:3.6.0=jarValidation,testCompileClasspath,testRuntimeClasspath
41-
com.squareup.okio:okio:3.6.0=jarValidation,testCompileClasspath,testRuntimeClasspath
40+
com.squareup.okio:okio-jvm:3.16.0=jarValidation,testCompileClasspath,testRuntimeClasspath
41+
com.squareup.okio:okio:3.16.0=jarValidation,testCompileClasspath,testRuntimeClasspath
4242
com.tdunning:t-digest:3.3=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
4343
commons-cli:commons-cli:1.10.0=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
4444
commons-codec:commons-codec:1.19.0=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testCompileClasspath,testRuntimeClasspath
@@ -176,7 +176,7 @@ org.glassfish.jersey.media:jersey-media-json-jackson:3.1.11=jarValidation,runtim
176176
org.hamcrest:hamcrest:3.0=jarValidation,testCompileClasspath,testRuntimeClasspath
177177
org.javassist:javassist:3.30.2-GA=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
178178
org.jetbrains.kotlin:kotlin-reflect:2.0.21=jarValidation,testRuntimeClasspath
179-
org.jetbrains.kotlin:kotlin-stdlib-common:2.2.0=jarValidation,testCompileClasspath,testRuntimeClasspath
179+
org.jetbrains.kotlin:kotlin-stdlib-common:2.2.0=jarValidation,testRuntimeClasspath
180180
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.2.0=jarValidation,testCompileClasspath,testRuntimeClasspath
181181
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.0=jarValidation,testCompileClasspath,testRuntimeClasspath
182182
org.jetbrains.kotlin:kotlin-stdlib:2.2.0=jarValidation,testCompileClasspath,testRuntimeClasspath

solr/modules/language-models/gradle.lockfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ com.jayway.jsonpath:json-path:2.9.0=jarValidation,runtimeClasspath,runtimeLibs,s
3232
com.knuddels:jtokkit:1.1.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
3333
com.lmax:disruptor:3.4.4=solrPlatformLibs
3434
com.squareup.okhttp3:okhttp:4.12.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
35-
com.squareup.okio:okio-jvm:3.6.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
36-
com.squareup.okio:okio:3.6.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
35+
com.squareup.okio:okio-jvm:3.16.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
36+
com.squareup.okio:okio:3.16.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
3737
com.squareup.retrofit2:converter-jackson:2.9.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
3838
com.squareup.retrofit2:retrofit:2.9.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
3939
com.tdunning:t-digest:3.3=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
@@ -164,7 +164,6 @@ org.glassfish.jersey.inject:jersey-hk2:3.1.11=jarValidation,runtimeClasspath,run
164164
org.glassfish.jersey.media:jersey-media-json-jackson:3.1.11=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
165165
org.hamcrest:hamcrest:3.0=jarValidation,testCompileClasspath,testRuntimeClasspath
166166
org.javassist:javassist:3.30.2-GA=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
167-
org.jetbrains.kotlin:kotlin-stdlib-common:2.2.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
168167
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.2.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
169168
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
170169
org.jetbrains.kotlin:kotlin-stdlib:2.2.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath

solr/server/etc/jetty-new-ui-dev.xml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,24 @@
2626
<!-- =============================================================== -->
2727

2828
<Configure id="Server" class="org.eclipse.jetty.server.Server">
29-
<Ref refid="RewriteHandler">
30-
<Call name="addRule">
31-
<Arg>
32-
<New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
33-
<Set name="pattern">/solr/ui/*</Set>
34-
<Set name="headerName">Content-Security-Policy</Set>
35-
<Set name="headerValue">default-src 'none'; base-uri 'none'; connect-src 'self'; form-action 'self'; font-src 'self'; frame-ancestors 'none'; img-src 'self' data:; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval'; worker-src 'self';</Set>
36-
</New>
37-
</Arg>
38-
</Call>
39-
</Ref>
29+
<Ref refid="RewriteHandler">
30+
<!-- SPA fallback: redirect all /solr/ui/* routes to index.html -->
31+
<Call name="addRule">
32+
<Arg>
33+
<New class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
34+
<Set name="regex">^(/solr/ui/[^.?]*)(\?.*)?$</Set>
35+
<Set name="replacement">/solr/ui/index.html</Set>
36+
</New>
37+
</Arg>
38+
</Call>
39+
<Call name="addRule">
40+
<Arg>
41+
<New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
42+
<Set name="pattern">/solr/ui/*</Set>
43+
<Set name="headerName">Content-Security-Policy</Set>
44+
<Set name="headerValue">default-src 'none'; base-uri 'none'; connect-src *; form-action 'self'; font-src 'self'; frame-ancestors 'none'; img-src 'self' data:; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval'; worker-src 'self';</Set>
45+
</New>
46+
</Arg>
47+
</Call>
48+
</Ref>
4049
</Configure>

solr/server/etc/jetty-new-ui-prod.xml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,24 @@
1313
<!-- =============================================================== -->
1414

1515
<Configure id="Server" class="org.eclipse.jetty.server.Server">
16-
<Ref refid="RewriteHandler">
17-
<Call name="addRule">
18-
<Arg>
19-
<New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
20-
<Set name="pattern">/solr/ui/*</Set>
21-
<Set name="headerName">Content-Security-Policy</Set>
22-
<Set name="headerValue">default-src 'none'; base-uri 'none'; connect-src 'self'; form-action 'self'; font-src 'self'; frame-ancestors 'none'; img-src 'self' data:; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'wasm-unsafe-eval'; worker-src 'self';</Set>
23-
</New>
24-
</Arg>
25-
</Call>
26-
</Ref>
16+
<Ref refid="RewriteHandler">
17+
<!-- SPA fallback: redirect all /solr/ui/* routes to index.html -->
18+
<Call name="addRule">
19+
<Arg>
20+
<New class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
21+
<Set name="regex">^(/solr/ui/[^.?]*)(\?.*)?$</Set>
22+
<Set name="replacement">/solr/ui/index.html</Set>
23+
</New>
24+
</Arg>
25+
</Call>
26+
<Call name="addRule">
27+
<Arg>
28+
<New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
29+
<Set name="pattern">/solr/ui/*</Set>
30+
<Set name="headerName">Content-Security-Policy</Set>
31+
<Set name="headerValue">default-src 'none'; base-uri 'none'; connect-src *; form-action 'self'; font-src 'self'; frame-ancestors 'none'; img-src 'self' data:; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'wasm-unsafe-eval'; worker-src 'self';</Set>
32+
</New>
33+
</Arg>
34+
</Call>
35+
</Ref>
2736
</Configure>

solr/ui/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ kotlin {
9696
implementation(libs.ktor.client.cio)
9797
implementation(libs.ktor.client.contentNegotiation)
9898
implementation(libs.ktor.client.serialization.json)
99+
implementation(libs.squareup.okio)
99100

100101
implementation(libs.oshai.logging)
101102
implementation(libs.slf4j.api)
@@ -114,6 +115,9 @@ kotlin {
114115

115116
val desktopMain by getting {
116117
dependencies {
118+
implementation(libs.ktor.server.core)
119+
implementation(libs.ktor.server.cio)
120+
implementation(libs.ktor.server.htmlBuilder)
117121
implementation(compose.desktop.currentOs)
118122
implementation(libs.kotlinx.coroutines.swing)
119123
}
@@ -132,6 +136,11 @@ compose.desktop {
132136
application {
133137
mainClass = "org.apache.solr.ui.MainKt"
134138

139+
buildTypes.release.proguard {
140+
version.set("7.6.0")
141+
configurationFiles.from("proguard.pro")
142+
}
143+
135144
nativeDistributions {
136145
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
137146

0 commit comments

Comments
 (0)