Compare commits
486
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a5087cf7e | ||
|
|
7a91cd5545 | ||
|
|
1e58a8207d | ||
|
|
dd48b01d83 | ||
|
|
f548c210e3 | ||
|
|
4569fb761d | ||
|
|
930da93182 | ||
|
|
05ae84d533 | ||
|
|
59674e44bf | ||
|
|
efaa88b4e3 | ||
|
|
f55a526ebb | ||
|
|
ccb9433e5c | ||
|
|
9d79a847c8 | ||
|
|
1630b9a20c | ||
|
|
65befb16fd | ||
|
|
e8f99a2109 | ||
|
|
7af16fc747 | ||
|
|
84f5c0926b | ||
|
|
11245701d2 | ||
|
|
5c45c5e6e4 | ||
|
|
04ee5ca7c1 | ||
|
|
df5d37a8d9 | ||
|
|
55a86dc0f4 | ||
|
|
fa8f60a5f0 | ||
|
|
2a5c778af5 | ||
|
|
f24d73e8d6 | ||
|
|
6d40e0dd07 | ||
|
|
529ef3a425 | ||
|
|
36bb94afb8 | ||
|
|
4fd0238ca9 | ||
|
|
76e1160b36 | ||
|
|
df3079852e | ||
|
|
71b648a9b6 | ||
|
|
ab7bb21991 | ||
|
|
348e0b6226 | ||
|
|
44b7210af7 | ||
|
|
f726caea9b | ||
|
|
16282aeb7b | ||
|
|
d2c546bdc2 | ||
|
|
1f27fc9e4b | ||
|
|
7c292b1213 | ||
|
|
3b9a6b32e1 | ||
|
|
b0bb0d36ab | ||
|
|
cdda19d1f8 | ||
|
|
759747ab5c | ||
|
|
01e48dc4b8 | ||
|
|
61b93c318f | ||
|
|
3f35234cf5 | ||
|
|
da135389c7 | ||
|
|
b3d7d48ec8 | ||
|
|
5a015a6518 | ||
|
|
7912bd4dae | ||
|
|
c860d03a60 | ||
|
|
1b2a5eda32 | ||
|
|
517413d38e | ||
|
|
fd25dbcb5c | ||
|
|
bdbc4e1f6d | ||
|
|
eebd496c2f | ||
|
|
15d31a202f | ||
|
|
6714c1a136 | ||
|
|
ca6d1f3c48 | ||
|
|
c5a149a892 | ||
|
|
b33648cc29 | ||
|
|
4a583712b8 | ||
|
|
5d20651c66 | ||
|
|
a49a288bbe | ||
|
|
fbace351b3 | ||
|
|
fbb2dfcf59 | ||
|
|
05813832fc | ||
|
|
e67f8c7a61 | ||
|
|
7a66b055be | ||
|
|
e3ddc5a639 | ||
|
|
8c5b1e4892 | ||
|
|
ad1d3adb9e | ||
|
|
e18f3edbcd | ||
|
|
6ede760725 | ||
|
|
db0f05fb86 | ||
|
|
03c05bd72b | ||
|
|
c867fcf9e7 | ||
|
|
22e85b11eb | ||
|
|
39fe439573 | ||
|
|
fc6b7ea8ee | ||
|
|
0e1edb3d7a | ||
|
|
7a77055e58 | ||
|
|
d9e95455a2 | ||
|
|
f5b4efc080 | ||
|
|
b1a233e41f | ||
|
|
4d6e656b02 | ||
|
|
3354e7c98e | ||
|
|
05fe17be4f | ||
|
|
2e9f14dfd8 | ||
|
|
404aa69adb | ||
|
|
a24a43c4be | ||
|
|
892d5fd1b7 | ||
|
|
258f7c8d60 | ||
|
|
b17bd9e660 | ||
|
|
43d23835d0 | ||
|
|
d11efa363c | ||
|
|
8f0afb2551 | ||
|
|
c874f96228 | ||
|
|
ce78cc1d1c | ||
|
|
599c69a2a3 | ||
|
|
9daced953e | ||
|
|
1b085d3e13 | ||
|
|
1bea93b1e1 | ||
|
|
16bd2fb8f8 | ||
|
|
e8efe10fc8 | ||
|
|
73bcfba5f3 | ||
|
|
02f28a7e8e | ||
|
|
5a4bb5f3f0 | ||
|
|
235623301e | ||
|
|
f4aee129e4 | ||
|
|
a7f9a6e095 | ||
|
|
539d9863aa | ||
|
|
4f51b7b34c | ||
|
|
0e5af3710e | ||
|
|
a462dd78bb | ||
|
|
ec5289b5c8 | ||
|
|
2a29f2a9c6 | ||
|
|
9ffd6548ce | ||
|
|
cfd41fbc8b | ||
|
|
4c2cca4672 | ||
|
|
53557d9cfd | ||
|
|
a0054bd77f | ||
|
|
099de9e6e3 | ||
|
|
cfd61dc359 | ||
|
|
99f453b25c | ||
|
|
d138b19adb | ||
|
|
345163994a | ||
|
|
09090cec24 | ||
|
|
3abcf713e5 | ||
|
|
e4d97485ec | ||
|
|
1489bd734a | ||
|
|
ef442cae92 | ||
|
|
3493aa4ab7 | ||
|
|
3be47dee37 | ||
|
|
494d9973a6 | ||
|
|
e28a3750cd | ||
|
|
014c8e068f | ||
|
|
3890867383 | ||
|
|
d499b8a489 | ||
|
|
352602da39 | ||
|
|
c333d1eaa9 | ||
|
|
c522a20ab9 | ||
|
|
ee66cb51da | ||
|
|
93d65fa895 | ||
|
|
6aafde7819 | ||
|
|
365a1b66c8 | ||
|
|
fa1fb3a3a9 | ||
|
|
b109ce14b0 | ||
|
|
561661d726 | ||
|
|
6592014707 | ||
|
|
4cd0a8e894 | ||
|
|
6c44e9befa | ||
|
|
8e9cfc4a28 | ||
|
|
d20d5ce2d7 | ||
|
|
243c8cc2cd | ||
|
|
7d444c8b13 | ||
|
|
be83e2fb6b | ||
|
|
b34acd4cc2 | ||
|
|
85ac784fd0 | ||
|
|
ab2368be34 | ||
|
|
ba076ad159 | ||
|
|
a8d2b810cf | ||
|
|
285a99d903 | ||
|
|
fd983690e2 | ||
|
|
006a0f856e | ||
|
|
bfe10e34e7 | ||
|
|
2cba13db9c | ||
|
|
3eb9134e02 | ||
|
|
b7f2e0b5ff | ||
|
|
27187c11f1 | ||
|
|
0030df060b | ||
|
|
f6f587e472 | ||
|
|
841c6b619a | ||
|
|
e0d70a35d6 | ||
|
|
0520d465c1 | ||
|
|
a8fb988e31 | ||
|
|
c34d175572 | ||
|
|
9c7442c75b | ||
|
|
de888fc8a1 | ||
|
|
4d8e19eb7c | ||
|
|
2df7d6252e | ||
|
|
d52e043322 | ||
|
|
6c8d55d534 | ||
|
|
26bc07b2c4 | ||
|
|
7f6fc170dc | ||
|
|
741bbf471f | ||
|
|
70eb27ec83 | ||
|
|
96b729886f | ||
|
|
530870f05e | ||
|
|
1633f062d5 | ||
|
|
ff703f935f | ||
|
|
4974079794 | ||
|
|
d94515cdae | ||
|
|
f838c697d1 | ||
|
|
d14de43ac7 | ||
|
|
e198e7e0b9 | ||
|
|
83306963e8 | ||
|
|
65e2f127c9 | ||
|
|
64c2077c0b | ||
|
|
9be6777685 | ||
|
|
f14f303dfe | ||
|
|
33d7d89ad9 | ||
|
|
65c49c39f4 | ||
|
|
6c0f685c39 | ||
|
|
e0a59baaf2 | ||
|
|
6a797a61a9 | ||
|
|
e49afb2d83 | ||
|
|
0d225f44de | ||
|
|
586f6eeece | ||
|
|
f91907c8f9 | ||
|
|
9e0667bc11 | ||
|
|
a3ffb32532 | ||
|
|
1e7cf9fb3f | ||
|
|
f75c0d3e61 | ||
|
|
534ee2e50c | ||
|
|
70722d0d3d | ||
|
|
0292acd5e2 | ||
|
|
bf3541414c | ||
|
|
9242e972c0 | ||
|
|
57a96fa6aa | ||
|
|
7f08717dfb | ||
|
|
9365a40426 | ||
|
|
ae58d64741 | ||
|
|
4a8b4bcdec | ||
|
|
e3aec098a2 | ||
|
|
3b9b673e5e | ||
|
|
17e75950fe | ||
|
|
1c75b03e59 | ||
|
|
27814dab65 | ||
|
|
b3a55df1e7 | ||
|
|
7ec3813a07 | ||
|
|
62b96143a1 | ||
|
|
ec6b81e42d | ||
|
|
3a5d4a3723 | ||
|
|
1d695237b7 | ||
|
|
09693eb108 | ||
|
|
3b3368eead | ||
|
|
a5cbe113fd | ||
|
|
9688880837 | ||
|
|
98be930027 | ||
|
|
83b4495e69 | ||
|
|
bd73b0aee6 | ||
|
|
ae1a7542d8 | ||
|
|
7d1bdf6e81 | ||
|
|
d64e7394a7 | ||
|
|
059011e82f | ||
|
|
eaf28f72c1 | ||
|
|
aa177dd9f9 | ||
|
|
a8a77add39 | ||
|
|
5facec73e4 | ||
|
|
91a267a0d8 | ||
|
|
0147fbe489 | ||
|
|
a9ccabdce5 | ||
|
|
e04ad9d7b6 | ||
|
|
c5d40a76ff | ||
|
|
79c7203fe8 | ||
|
|
0d99b797b6 | ||
|
|
59f228be2b | ||
|
|
159b752fb0 | ||
|
|
b0c7746eeb | ||
|
|
bbeac6d741 | ||
|
|
a8eb3ca65a | ||
|
|
fea277a7f5 | ||
|
|
cd94778dec | ||
|
|
bd5b434894 | ||
|
|
26f0f6509a | ||
|
|
7983ed064f | ||
|
|
607b305c2f | ||
|
|
8ad3c3fb03 | ||
|
|
824890323d | ||
|
|
5011960cac | ||
|
|
3c8ed8e3d8 | ||
|
|
e6ce2e138d | ||
|
|
8cfa50f134 | ||
|
|
2b3859f462 | ||
|
|
5d9fe09599 | ||
|
|
2219cd363e | ||
|
|
b08800fbd8 | ||
|
|
7e1b97888a | ||
|
|
322597b420 | ||
|
|
bd499e1c55 | ||
|
|
46b4bb0909 | ||
|
|
59e0570cdf | ||
|
|
c925033944 | ||
|
|
94f583e935 | ||
|
|
69f051fb0a | ||
|
|
3973aed57d | ||
|
|
73d3db6d00 | ||
|
|
535a0763fc | ||
|
|
283581f920 | ||
|
|
488dee71d2 | ||
|
|
b6811b96b9 | ||
|
|
db852f7e11 | ||
|
|
01830fd7f3 | ||
|
|
00d439b6f0 | ||
|
|
06fca9c897 | ||
|
|
72d134748c | ||
|
|
e2ad7608c8 | ||
|
|
a73dd537f3 | ||
|
|
9169bcd88d | ||
|
|
94af2e1789 | ||
|
|
56e011dce4 | ||
|
|
079026a7be | ||
|
|
7c6cf8f3b7 | ||
|
|
981ff90c81 | ||
|
|
484d5d6e08 | ||
|
|
0315bd0b87 | ||
|
|
2a05f00d0c | ||
|
|
05a804b972 | ||
|
|
f4ddfe4a52 | ||
|
|
76c4fbb241 | ||
|
|
3b0fd71155 | ||
|
|
6f92bac782 | ||
|
|
8b535c5da6 | ||
|
|
e719722e32 | ||
|
|
c709598fdd | ||
|
|
3ef0527a91 | ||
|
|
eb12a307f7 | ||
|
|
f36a68308d | ||
|
|
7571dc07f9 | ||
|
|
e03bf6eef6 | ||
|
|
0e470d75e9 | ||
|
|
187f4a49ad | ||
|
|
0a5e061ca6 | ||
|
|
1b517a461e | ||
|
|
a913b8a158 | ||
|
|
f574173ed3 | ||
|
|
a6bdf81e6d | ||
|
|
a42e4af78d | ||
|
|
b1ae0a9000 | ||
|
|
07d7141d98 | ||
|
|
0632bc8939 | ||
|
|
e708c53730 | ||
|
|
243105f952 | ||
|
|
1ce17c459d | ||
|
|
daa4d23ac0 | ||
|
|
30d651bcee | ||
|
|
fda0a79e27 | ||
|
|
021c2ec701 | ||
|
|
fbf00ba1cd | ||
|
|
a2ead8743f | ||
|
|
5a0b86f814 | ||
|
|
970c89dd6a | ||
|
|
f9bfb5d3e5 | ||
|
|
f384c2340e | ||
|
|
2f14fb7fb7 | ||
|
|
fe367d207a | ||
|
|
13a21e5fda | ||
|
|
dcc4ea3aea | ||
|
|
7bc34c0ba4 | ||
|
|
aacf2e9390 | ||
|
|
966a580895 | ||
|
|
bffbc9e198 | ||
|
|
ee3ac3fdaf | ||
|
|
9ddec7d1eb | ||
|
|
4f1d83b9dc | ||
|
|
eeabc0092b | ||
|
|
ea44b5888b | ||
|
|
abde62f369 | ||
|
|
16184d1e9d | ||
|
|
38f89b93ff | ||
|
|
912bc8464e | ||
|
|
d5199501c7 | ||
|
|
f9235cb07d | ||
|
|
d7649c2547 | ||
|
|
be5468a7cf | ||
|
|
eba56e4784 | ||
|
|
26efb2cbee | ||
|
|
02896768f5 | ||
|
|
1d4e76117c | ||
|
|
a912ba3148 | ||
|
|
5b0980172d | ||
|
|
ff8dce77f3 | ||
|
|
7dbdb023a0 | ||
|
|
2fa200889a | ||
|
|
f97d0846ed | ||
|
|
19e5ddeba5 | ||
|
|
df090fa5e1 | ||
|
|
c283f9803c | ||
|
|
3a370e2726 | ||
|
|
73cbf857c1 | ||
|
|
64ad222a28 | ||
|
|
6e94931023 | ||
|
|
ba3b6fd564 | ||
|
|
039bb103c2 | ||
|
|
e946c1c512 | ||
|
|
c67d834d39 | ||
|
|
8bdfd57e9b | ||
|
|
629390dd4a | ||
|
|
3bfd999590 | ||
|
|
80a67149af | ||
|
|
7962f68991 | ||
|
|
c10a005997 | ||
|
|
4dd28c0adf | ||
|
|
4bdd67da79 | ||
|
|
8e24c73ac8 | ||
|
|
bd2887aa77 | ||
|
|
bdc57d57c1 | ||
|
|
38cc183be5 | ||
|
|
930b0d9ad7 | ||
|
|
bf2ca4008e | ||
|
|
a7c9e71490 | ||
|
|
0040d3fc3b | ||
|
|
7e5a5f79cf | ||
|
|
7a161cc8bb | ||
|
|
c5e8a010dc | ||
|
|
5638e9e1c5 | ||
|
|
56e09bf189 | ||
|
|
7aafbcd5d9 | ||
|
|
78fbf45b80 | ||
|
|
bd124d5f9b | ||
|
|
5ef65e837c | ||
|
|
2591dd862b | ||
|
|
159b371973 | ||
|
|
948f37b01a | ||
|
|
1f41b3195f | ||
|
|
4628946a55 | ||
|
|
a231c1b31b | ||
|
|
3fc215d041 | ||
|
|
fed7339558 | ||
|
|
7e0238d1c7 | ||
|
|
2dd0d7189e | ||
|
|
f52504ac41 | ||
|
|
7cfee80e58 | ||
|
|
435cdb6180 | ||
|
|
fe856d3fa7 | ||
|
|
98923d0ea4 | ||
|
|
dd6434a487 | ||
|
|
842b811a41 | ||
|
|
07ab632351 | ||
|
|
9bcfda64fa | ||
|
|
453859d14f | ||
|
|
122cb1f490 | ||
|
|
6bb59b7f63 | ||
|
|
1ec88cf5b0 | ||
|
|
74139ec787 | ||
|
|
f3a780cc2d | ||
|
|
00cb0a798a | ||
|
|
c9bbfc3b0b | ||
|
|
cb085cc598 | ||
|
|
a8b39edd73 | ||
|
|
8b8ebfc7e1 | ||
|
|
d90a708ceb | ||
|
|
450b57c76a | ||
|
|
fa312fb3db | ||
|
|
9384aa1398 | ||
|
|
ce7e7ef1d7 | ||
|
|
a19469aba5 | ||
|
|
b224917fc5 | ||
|
|
3f1eecc4be | ||
|
|
3ba3be877e | ||
|
|
daefbcf994 | ||
|
|
5d9669e5a6 | ||
|
|
1e7745b5c3 | ||
|
|
46d02f15fe | ||
|
|
01f3dddd91 | ||
|
|
2db41ef052 | ||
|
|
afa9471c7c | ||
|
|
08f28de903 | ||
|
|
1fe8da67dc | ||
|
|
591a794247 | ||
|
|
a9e8f315a4 | ||
|
|
c738f9fbd3 | ||
|
|
588f6ba253 | ||
|
|
a9f6948d74 | ||
|
|
f51098c50b | ||
|
|
8b0bf503c3 | ||
|
|
ec402f759b | ||
|
|
bc82f18acb | ||
|
|
a001d53d2a | ||
|
|
1a4d03e283 | ||
|
|
8a8bf47043 | ||
|
|
836ab2820a | ||
|
|
01d0821142 | ||
|
|
47fab2d034 | ||
|
|
fc295ac2ac | ||
|
|
69919902b4 | ||
|
|
a6af72cbbc | ||
|
|
4aa102fcab | ||
|
|
0dc8bb7c3b | ||
|
|
5e450d5cd4 | ||
|
|
38722e8273 | ||
|
|
61be5cc90e | ||
|
|
1422d2962e |
No files matched your search
+8
-1
@@ -1,5 +1,12 @@
|
|||||||
language: java
|
language: java
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.m2
|
||||||
|
|
||||||
|
before_cache:
|
||||||
|
- rm -rf $HOME/.m2/repository/org/keycloak
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- MAVEN_SKIP_RC=true
|
- MAVEN_SKIP_RC=true
|
||||||
@@ -12,7 +19,7 @@ before_script:
|
|||||||
- export MAVEN_SKIP_RC=true
|
- export MAVEN_SKIP_RC=true
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- mvn install -Pdistribution -DskipTests=true -B -V -q
|
- travis_wait 30 mvn install -Pdistribution -DskipTests=true -B -V -q
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- mvn test -B
|
- mvn test -B
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ Contributing
|
|||||||
* [Testsuite](misc/Testsuite.md) - Details about testsuite, but also how to quickly run Keycloak during development and a few test tools (OTP generation, LDAP server, Mail server)
|
* [Testsuite](misc/Testsuite.md) - Details about testsuite, but also how to quickly run Keycloak during development and a few test tools (OTP generation, LDAP server, Mail server)
|
||||||
* [Database Testing](misc/DatabaseTesting.md) - How to do testing of Keycloak on different databases
|
* [Database Testing](misc/DatabaseTesting.md) - How to do testing of Keycloak on different databases
|
||||||
* [Updating Database](misc/UpdatingDatabaseSchema.md) - How to change the Keycloak database
|
* [Updating Database](misc/UpdatingDatabaseSchema.md) - How to change the Keycloak database
|
||||||
|
* [Changing the Default keycloak-subsystem Configuration](misc/UpdatingServerConfig.md) - How to update the default keycloak-subsystem config
|
||||||
* [Developer Mailing List](https://lists.jboss.org/mailman/listinfo/keycloak-dev) - Mailing list to discuss development of Keycloak
|
* [Developer Mailing List](https://lists.jboss.org/mailman/listinfo/keycloak-dev) - Mailing list to discuss development of Keycloak
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+15
-2
@@ -34,6 +34,7 @@ import org.keycloak.representations.AccessTokenResponse;
|
|||||||
import org.keycloak.representations.IDToken;
|
import org.keycloak.representations.IDToken;
|
||||||
import org.keycloak.common.util.KeycloakUriBuilder;
|
import org.keycloak.common.util.KeycloakUriBuilder;
|
||||||
import org.keycloak.common.util.UriUtils;
|
import org.keycloak.common.util.UriUtils;
|
||||||
|
import org.keycloak.util.TokenUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
@@ -159,6 +160,12 @@ public class OAuthRequestAuthenticator {
|
|||||||
String scope = getQueryParamValue(OAuth2Constants.SCOPE);
|
String scope = getQueryParamValue(OAuth2Constants.SCOPE);
|
||||||
url = UriUtils.stripQueryParam(url, OAuth2Constants.SCOPE);
|
url = UriUtils.stripQueryParam(url, OAuth2Constants.SCOPE);
|
||||||
|
|
||||||
|
String prompt = getQueryParamValue(OAuth2Constants.PROMPT);
|
||||||
|
url = UriUtils.stripQueryParam(url, OAuth2Constants.PROMPT);
|
||||||
|
|
||||||
|
String maxAge = getQueryParamValue(OAuth2Constants.MAX_AGE);
|
||||||
|
url = UriUtils.stripQueryParam(url, OAuth2Constants.MAX_AGE);
|
||||||
|
|
||||||
KeycloakUriBuilder redirectUriBuilder = deployment.getAuthUrl().clone()
|
KeycloakUriBuilder redirectUriBuilder = deployment.getAuthUrl().clone()
|
||||||
.queryParam(OAuth2Constants.RESPONSE_TYPE, OAuth2Constants.CODE)
|
.queryParam(OAuth2Constants.RESPONSE_TYPE, OAuth2Constants.CODE)
|
||||||
.queryParam(OAuth2Constants.CLIENT_ID, deployment.getResourceName())
|
.queryParam(OAuth2Constants.CLIENT_ID, deployment.getResourceName())
|
||||||
@@ -171,9 +178,15 @@ public class OAuthRequestAuthenticator {
|
|||||||
if (idpHint != null && idpHint.length() > 0) {
|
if (idpHint != null && idpHint.length() > 0) {
|
||||||
redirectUriBuilder.queryParam(AdapterConstants.KC_IDP_HINT,idpHint);
|
redirectUriBuilder.queryParam(AdapterConstants.KC_IDP_HINT,idpHint);
|
||||||
}
|
}
|
||||||
if (scope != null && scope.length() > 0) {
|
if (prompt != null && prompt.length() > 0) {
|
||||||
redirectUriBuilder.queryParam(OAuth2Constants.SCOPE, scope);
|
redirectUriBuilder.queryParam(OAuth2Constants.PROMPT, prompt);
|
||||||
}
|
}
|
||||||
|
if (maxAge != null && maxAge.length() > 0) {
|
||||||
|
redirectUriBuilder.queryParam(OAuth2Constants.MAX_AGE, maxAge);
|
||||||
|
}
|
||||||
|
|
||||||
|
scope = TokenUtil.attachOIDCScope(scope);
|
||||||
|
redirectUriBuilder.queryParam(OAuth2Constants.SCOPE, scope);
|
||||||
|
|
||||||
return redirectUriBuilder.build().toString();
|
return redirectUriBuilder.build().toString();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -35,7 +35,8 @@ public class OIDCAuthenticationError implements AuthenticationError {
|
|||||||
CODE_TO_TOKEN_FAILURE,
|
CODE_TO_TOKEN_FAILURE,
|
||||||
INVALID_TOKEN,
|
INVALID_TOKEN,
|
||||||
STALE_TOKEN,
|
STALE_TOKEN,
|
||||||
NO_AUTHORIZATION_HEADER
|
NO_AUTHORIZATION_HEADER,
|
||||||
|
NO_QUERY_PARAMETER_ACCESS_TOKEN
|
||||||
}
|
}
|
||||||
|
|
||||||
private Reason reason;
|
private Reason reason;
|
||||||
|
|||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.keycloak.adapters;
|
||||||
|
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
import org.keycloak.adapters.spi.AuthOutcome;
|
||||||
|
import org.keycloak.adapters.spi.HttpFacade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:froehlich.ch@gmail.com">Christian Froehlich</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class QueryParamterTokenRequestAuthenticator extends BearerTokenRequestAuthenticator {
|
||||||
|
public static final String ACCESS_TOKEN = "access_token";
|
||||||
|
protected Logger log = Logger.getLogger(QueryParamterTokenRequestAuthenticator.class);
|
||||||
|
|
||||||
|
public QueryParamterTokenRequestAuthenticator(KeycloakDeployment deployment) {
|
||||||
|
super(deployment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthOutcome authenticate(HttpFacade exchange) {
|
||||||
|
tokenString = null;
|
||||||
|
tokenString = getAccessTokenFromQueryParamter(exchange);
|
||||||
|
if (tokenString == null || tokenString.trim().isEmpty()) {
|
||||||
|
challenge = challengeResponse(exchange, OIDCAuthenticationError.Reason.NO_QUERY_PARAMETER_ACCESS_TOKEN, null, null);
|
||||||
|
return AuthOutcome.NOT_ATTEMPTED;
|
||||||
|
}
|
||||||
|
return (authenticateToken(exchange, tokenString));
|
||||||
|
}
|
||||||
|
|
||||||
|
String getAccessTokenFromQueryParamter(HttpFacade exchange) {
|
||||||
|
try {
|
||||||
|
if (exchange != null && exchange.getRequest() != null) {
|
||||||
|
return exchange.getRequest().getQueryParamValue(ACCESS_TOKEN);
|
||||||
|
}
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -74,6 +74,23 @@ public abstract class RequestAuthenticator {
|
|||||||
return AuthOutcome.AUTHENTICATED;
|
return AuthOutcome.AUTHENTICATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QueryParamterTokenRequestAuthenticator queryParamAuth = createQueryParamterTokenRequestAuthenticator();
|
||||||
|
if (log.isTraceEnabled()) {
|
||||||
|
log.trace("try query paramter auth");
|
||||||
|
}
|
||||||
|
|
||||||
|
outcome = queryParamAuth.authenticate(facade);
|
||||||
|
if (outcome == AuthOutcome.FAILED) {
|
||||||
|
challenge = queryParamAuth.getChallenge();
|
||||||
|
log.debug("QueryParamAuth auth FAILED");
|
||||||
|
return AuthOutcome.FAILED;
|
||||||
|
} else if (outcome == AuthOutcome.AUTHENTICATED) {
|
||||||
|
if (verifySSL()) return AuthOutcome.FAILED;
|
||||||
|
log.debug("QueryParamAuth AUTHENTICATED");
|
||||||
|
completeAuthentication(queryParamAuth, "KEYCLOAK");
|
||||||
|
return AuthOutcome.AUTHENTICATED;
|
||||||
|
}
|
||||||
|
|
||||||
if (deployment.isEnableBasicAuth()) {
|
if (deployment.isEnableBasicAuth()) {
|
||||||
BasicAuthRequestAuthenticator basicAuth = createBasicAuthAuthenticator();
|
BasicAuthRequestAuthenticator basicAuth = createBasicAuthAuthenticator();
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
@@ -86,6 +103,7 @@ public abstract class RequestAuthenticator {
|
|||||||
log.debug("BasicAuth FAILED");
|
log.debug("BasicAuth FAILED");
|
||||||
return AuthOutcome.FAILED;
|
return AuthOutcome.FAILED;
|
||||||
} else if (outcome == AuthOutcome.AUTHENTICATED) {
|
} else if (outcome == AuthOutcome.AUTHENTICATED) {
|
||||||
|
if (verifySSL()) return AuthOutcome.FAILED;
|
||||||
log.debug("BasicAuth AUTHENTICATED");
|
log.debug("BasicAuth AUTHENTICATED");
|
||||||
completeAuthentication(basicAuth, "BASIC");
|
completeAuthentication(basicAuth, "BASIC");
|
||||||
return AuthOutcome.AUTHENTICATED;
|
return AuthOutcome.AUTHENTICATED;
|
||||||
@@ -150,6 +168,10 @@ public abstract class RequestAuthenticator {
|
|||||||
return new BasicAuthRequestAuthenticator(deployment);
|
return new BasicAuthRequestAuthenticator(deployment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected QueryParamterTokenRequestAuthenticator createQueryParamterTokenRequestAuthenticator() {
|
||||||
|
return new QueryParamterTokenRequestAuthenticator(deployment);
|
||||||
|
}
|
||||||
|
|
||||||
protected void completeAuthentication(OAuthRequestAuthenticator oauth) {
|
protected void completeAuthentication(OAuthRequestAuthenticator oauth) {
|
||||||
RefreshableKeycloakSecurityContext session = new RefreshableKeycloakSecurityContext(deployment, tokenStore, oauth.getTokenString(), oauth.getToken(), oauth.getIdTokenString(), oauth.getIdToken(), oauth.getRefreshToken());
|
RefreshableKeycloakSecurityContext session = new RefreshableKeycloakSecurityContext(deployment, tokenStore, oauth.getTokenString(), oauth.getToken(), oauth.getIdTokenString(), oauth.getIdToken(), oauth.getRefreshToken());
|
||||||
final KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal = new KeycloakPrincipal<RefreshableKeycloakSecurityContext>(AdapterUtils.getPrincipalName(deployment, oauth.getToken()), session);
|
final KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal = new KeycloakPrincipal<RefreshableKeycloakSecurityContext>(AdapterUtils.getPrincipalName(deployment, oauth.getToken()), session);
|
||||||
@@ -158,10 +180,12 @@ public abstract class RequestAuthenticator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void completeOAuthAuthentication(KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal);
|
protected abstract void completeOAuthAuthentication(KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal);
|
||||||
|
|
||||||
protected abstract void completeBearerAuthentication(KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal, String method);
|
protected abstract void completeBearerAuthentication(KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal, String method);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After code is received, we change the session id if possible to guard against https://www.owasp.org/index.php/Session_Fixation
|
* After code is received, we change the session id if possible to guard against https://www.owasp.org/index.php/Session_Fixation
|
||||||
|
*
|
||||||
* @param create
|
* @param create
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
+4
@@ -54,6 +54,10 @@ public class JWTClientCredentialsProvider implements ClientCredentialsProvider {
|
|||||||
this.tokenTimeout = tokenTimeout;
|
this.tokenTimeout = tokenTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getTokenTimeout() {
|
||||||
|
return tokenTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(KeycloakDeployment deployment, Object config) {
|
public void init(KeycloakDeployment deployment, Object config) {
|
||||||
if (config == null || !(config instanceof Map)) {
|
if (config == null || !(config instanceof Map)) {
|
||||||
|
|||||||
+20
-10
@@ -29,9 +29,10 @@ import org.keycloak.representations.AccessToken;
|
|||||||
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig;
|
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig;
|
||||||
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig.EnforcementMode;
|
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig.EnforcementMode;
|
||||||
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig.PathConfig;
|
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig.PathConfig;
|
||||||
import org.keycloak.representations.authorization.Permission;
|
import org.keycloak.representations.idm.authorization.Permission;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -55,7 +56,7 @@ public abstract class AbstractPolicyEnforcer {
|
|||||||
this.enforcerConfig = policyEnforcer.getEnforcerConfig();
|
this.enforcerConfig = policyEnforcer.getEnforcerConfig();
|
||||||
this.authzClient = policyEnforcer.getClient();
|
this.authzClient = policyEnforcer.getClient();
|
||||||
this.pathMatcher = new PathMatcher();
|
this.pathMatcher = new PathMatcher();
|
||||||
this.paths = policyEnforcer.getPaths();
|
this.paths = new ArrayList<>(policyEnforcer.getPaths());
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthorizationContext authorize(OIDCHttpFacade httpFacade) {
|
public AuthorizationContext authorize(OIDCHttpFacade httpFacade) {
|
||||||
@@ -126,11 +127,13 @@ public abstract class AbstractPolicyEnforcer {
|
|||||||
List<Permission> permissions = authorization.getPermissions();
|
List<Permission> permissions = authorization.getPermissions();
|
||||||
|
|
||||||
for (Permission permission : permissions) {
|
for (Permission permission : permissions) {
|
||||||
Set<String> allowedScopes = permission.getScopes();
|
|
||||||
|
|
||||||
if (permission.getResourceSetId() != null) {
|
if (permission.getResourceSetId() != null) {
|
||||||
if (isResourcePermission(actualPathConfig, permission)) {
|
if (isResourcePermission(actualPathConfig, permission)) {
|
||||||
if (((allowedScopes == null || allowedScopes.isEmpty()) && requiredScopes.isEmpty()) || allowedScopes.containsAll(requiredScopes)) {
|
if (actualPathConfig.isInstance() && !matchResourcePermission(actualPathConfig, permission)) {
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (hasResourceScopePermission(requiredScopes, permission, actualPathConfig)) {
|
||||||
LOGGER.debugf("Authorization GRANTED for path [%s]. Permissions [%s].", actualPathConfig, permissions);
|
LOGGER.debugf("Authorization GRANTED for path [%s]. Permissions [%s].", actualPathConfig, permissions);
|
||||||
if (request.getMethod().equalsIgnoreCase("DELETE") && actualPathConfig.isInstance()) {
|
if (request.getMethod().equalsIgnoreCase("DELETE") && actualPathConfig.isInstance()) {
|
||||||
this.paths.remove(actualPathConfig);
|
this.paths.remove(actualPathConfig);
|
||||||
@@ -139,8 +142,7 @@ public abstract class AbstractPolicyEnforcer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((allowedScopes.isEmpty() && requiredScopes.isEmpty()) || allowedScopes.containsAll(requiredScopes)) {
|
if (hasResourceScopePermission(requiredScopes, permission, actualPathConfig)) {
|
||||||
LOGGER.debugf("Authorization GRANTED for path [%s]. Permissions [%s].", actualPathConfig, permissions);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,6 +153,11 @@ public abstract class AbstractPolicyEnforcer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasResourceScopePermission(Set<String> requiredScopes, Permission permission, PathConfig actualPathConfig) {
|
||||||
|
Set<String> allowedScopes = permission.getScopes();
|
||||||
|
return (allowedScopes.containsAll(requiredScopes) || allowedScopes.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
protected AuthzClient getAuthzClient() {
|
protected AuthzClient getAuthzClient() {
|
||||||
return this.authzClient;
|
return this.authzClient;
|
||||||
}
|
}
|
||||||
@@ -210,7 +217,6 @@ public abstract class AbstractPolicyEnforcer {
|
|||||||
config.setPath(targetResource.getUri());
|
config.setPath(targetResource.getUri());
|
||||||
config.setScopes(originalConfig.getScopes());
|
config.setScopes(originalConfig.getScopes());
|
||||||
config.setMethods(originalConfig.getMethods());
|
config.setMethods(originalConfig.getMethods());
|
||||||
config.setInstance(true);
|
|
||||||
config.setParentConfig(originalConfig);
|
config.setParentConfig(originalConfig);
|
||||||
|
|
||||||
this.paths.add(config);
|
this.paths.add(config);
|
||||||
@@ -244,13 +250,17 @@ public abstract class AbstractPolicyEnforcer {
|
|||||||
|
|
||||||
private boolean isResourcePermission(PathConfig actualPathConfig, Permission permission) {
|
private boolean isResourcePermission(PathConfig actualPathConfig, Permission permission) {
|
||||||
// first we try a match using resource id
|
// first we try a match using resource id
|
||||||
boolean resourceMatch = permission.getResourceSetId().equals(actualPathConfig.getId());
|
boolean resourceMatch = matchResourcePermission(actualPathConfig, permission);
|
||||||
|
|
||||||
// as a fallback, check if the current path is an instance and if so, check if parent's id matches the permission
|
// as a fallback, check if the current path is an instance and if so, check if parent's id matches the permission
|
||||||
if (!resourceMatch && actualPathConfig.isInstance()) {
|
if (!resourceMatch && actualPathConfig.isInstance()) {
|
||||||
resourceMatch = permission.getResourceSetId().equals(actualPathConfig.getParentConfig().getId());
|
resourceMatch = matchResourcePermission(actualPathConfig.getParentConfig(), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceMatch;
|
return resourceMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean matchResourcePermission(PathConfig actualPathConfig, Permission permission) {
|
||||||
|
return permission.getResourceSetId().equals(actualPathConfig.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+34
-2
@@ -26,12 +26,17 @@ import org.keycloak.authorization.client.AuthorizationDeniedException;
|
|||||||
import org.keycloak.authorization.client.AuthzClient;
|
import org.keycloak.authorization.client.AuthzClient;
|
||||||
import org.keycloak.authorization.client.representation.AuthorizationRequest;
|
import org.keycloak.authorization.client.representation.AuthorizationRequest;
|
||||||
import org.keycloak.authorization.client.representation.AuthorizationResponse;
|
import org.keycloak.authorization.client.representation.AuthorizationResponse;
|
||||||
|
import org.keycloak.authorization.client.representation.EntitlementRequest;
|
||||||
import org.keycloak.authorization.client.representation.EntitlementResponse;
|
import org.keycloak.authorization.client.representation.EntitlementResponse;
|
||||||
import org.keycloak.authorization.client.representation.PermissionRequest;
|
import org.keycloak.authorization.client.representation.PermissionRequest;
|
||||||
import org.keycloak.authorization.client.representation.PermissionResponse;
|
import org.keycloak.authorization.client.representation.PermissionResponse;
|
||||||
import org.keycloak.representations.AccessToken;
|
import org.keycloak.representations.AccessToken;
|
||||||
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig.PathConfig;
|
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig.PathConfig;
|
||||||
|
import org.keycloak.representations.idm.authorization.Permission;
|
||||||
|
import org.keycloak.util.JsonSerialization;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,9 +55,8 @@ public class KeycloakAdapterPolicyEnforcer extends AbstractPolicyEnforcer {
|
|||||||
int retry = 2;
|
int retry = 2;
|
||||||
AccessToken original = accessToken;
|
AccessToken original = accessToken;
|
||||||
|
|
||||||
while (retry >= 0) {
|
while (retry > 0) {
|
||||||
if (super.isAuthorized(pathConfig, requiredScopes, accessToken, httpFacade)) {
|
if (super.isAuthorized(pathConfig, requiredScopes, accessToken, httpFacade)) {
|
||||||
original.setAuthorization(accessToken.getAuthorization());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +66,21 @@ public class KeycloakAdapterPolicyEnforcer extends AbstractPolicyEnforcer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AccessToken.Authorization authorization = original.getAuthorization();
|
||||||
|
|
||||||
|
if (authorization == null) {
|
||||||
|
authorization = new AccessToken.Authorization();
|
||||||
|
authorization.setPermissions(new ArrayList<Permission>());
|
||||||
|
}
|
||||||
|
|
||||||
|
AccessToken.Authorization newAuthorization = accessToken.getAuthorization();
|
||||||
|
|
||||||
|
if (newAuthorization != null) {
|
||||||
|
authorization.getPermissions().addAll(newAuthorization.getPermissions());
|
||||||
|
}
|
||||||
|
|
||||||
|
original.setAuthorization(authorization);
|
||||||
|
|
||||||
retry--;
|
retry--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +126,21 @@ public class KeycloakAdapterPolicyEnforcer extends AbstractPolicyEnforcer {
|
|||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
LOGGER.debug("Obtaining entitlements for authenticated user.");
|
LOGGER.debug("Obtaining entitlements for authenticated user.");
|
||||||
|
AccessToken token = httpFacade.getSecurityContext().getToken();
|
||||||
|
|
||||||
|
if (token.getAuthorization() == null) {
|
||||||
EntitlementResponse authzResponse = authzClient.entitlement(accessToken).getAll(authzClient.getConfiguration().getClientId());
|
EntitlementResponse authzResponse = authzClient.entitlement(accessToken).getAll(authzClient.getConfiguration().getClientId());
|
||||||
return RSATokenVerifier.verifyToken(authzResponse.getRpt(), deployment.getRealmKey(), deployment.getRealmInfoUrl());
|
return RSATokenVerifier.verifyToken(authzResponse.getRpt(), deployment.getRealmKey(), deployment.getRealmInfoUrl());
|
||||||
|
} else {
|
||||||
|
EntitlementRequest request = new EntitlementRequest();
|
||||||
|
PermissionRequest permissionRequest = new PermissionRequest();
|
||||||
|
permissionRequest.setResourceSetId(pathConfig.getId());
|
||||||
|
permissionRequest.setResourceSetName(pathConfig.getName());
|
||||||
|
permissionRequest.setScopes(new HashSet<>(pathConfig.getScopes()));
|
||||||
|
request.addPermission(permissionRequest);
|
||||||
|
EntitlementResponse authzResponse = authzClient.entitlement(accessToken).get(authzClient.getConfiguration().getClientId(), request);
|
||||||
|
return RSATokenVerifier.verifyToken(authzResponse.getRpt(), deployment.getRealmKey(), deployment.getRealmInfoUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (AuthorizationDeniedException e) {
|
} catch (AuthorizationDeniedException e) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+22
-6
@@ -30,11 +30,15 @@ import org.keycloak.authorization.client.resource.ProtectedResource;
|
|||||||
import org.keycloak.representations.adapters.config.AdapterConfig;
|
import org.keycloak.representations.adapters.config.AdapterConfig;
|
||||||
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig;
|
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig;
|
||||||
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig.PathConfig;
|
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig.PathConfig;
|
||||||
import org.keycloak.representations.authorization.Permission;
|
import org.keycloak.representations.idm.authorization.Permission;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +49,6 @@ public class PolicyEnforcer {
|
|||||||
private static Logger LOGGER = Logger.getLogger(PolicyEnforcer.class);
|
private static Logger LOGGER = Logger.getLogger(PolicyEnforcer.class);
|
||||||
|
|
||||||
private final KeycloakDeployment deployment;
|
private final KeycloakDeployment deployment;
|
||||||
private final PathMatcher pathMatcher;
|
|
||||||
private final AuthzClient authzClient;
|
private final AuthzClient authzClient;
|
||||||
private final PolicyEnforcerConfig enforcerConfig;
|
private final PolicyEnforcerConfig enforcerConfig;
|
||||||
private final List<PathConfig> paths;
|
private final List<PathConfig> paths;
|
||||||
@@ -54,7 +57,6 @@ public class PolicyEnforcer {
|
|||||||
this.deployment = deployment;
|
this.deployment = deployment;
|
||||||
this.enforcerConfig = adapterConfig.getPolicyEnforcerConfig();
|
this.enforcerConfig = adapterConfig.getPolicyEnforcerConfig();
|
||||||
this.authzClient = AuthzClient.create(new Configuration(adapterConfig.getAuthServerUrl(), adapterConfig.getRealm(), adapterConfig.getResource(), adapterConfig.getCredentials(), deployment.getClient()));
|
this.authzClient = AuthzClient.create(new Configuration(adapterConfig.getAuthServerUrl(), adapterConfig.getRealm(), adapterConfig.getResource(), adapterConfig.getCredentials(), deployment.getClient()));
|
||||||
this.pathMatcher = new PathMatcher();
|
|
||||||
this.paths = configurePaths(this.authzClient.protection().resource(), this.enforcerConfig);
|
this.paths = configurePaths(this.authzClient.protection().resource(), this.enforcerConfig);
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
@@ -97,8 +99,8 @@ public class PolicyEnforcer {
|
|||||||
return authzClient;
|
return authzClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PathConfig> getPaths() {
|
public List<PathConfig> getPaths() {
|
||||||
return paths;
|
return Collections.unmodifiableList(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeycloakDeployment getDeployment() {
|
KeycloakDeployment getDeployment() {
|
||||||
@@ -156,13 +158,27 @@ public class PolicyEnforcer {
|
|||||||
|
|
||||||
pathConfig.setId(registrationResponse.getId());
|
pathConfig.setId(registrationResponse.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Could not find matching resource on server with uri [" + path + "] or name [" + resourceName + ". Make sure you have created a resource on the server that matches with the path configuration.");
|
throw new RuntimeException("Could not find matching resource on server with uri [" + path + "] or name [" + resourceName + "]. Make sure you have created a resource on the server that matches with the path configuration.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pathConfig.setId(search.iterator().next());
|
pathConfig.setId(search.iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PathConfig existingPath = null;
|
||||||
|
|
||||||
|
for (PathConfig current : paths) {
|
||||||
|
if (current.getId().equals(pathConfig.getId()) && current.getPath().equals(pathConfig.getPath())) {
|
||||||
|
existingPath = current;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingPath == null) {
|
||||||
paths.add(pathConfig);
|
paths.add(pathConfig);
|
||||||
|
} else {
|
||||||
|
existingPath.getMethods().addAll(pathConfig.getMethods());
|
||||||
|
existingPath.getScopes().addAll(pathConfig.getScopes());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
|
|||||||
+7
-6
@@ -43,6 +43,7 @@ import org.keycloak.common.VerificationException;
|
|||||||
import org.keycloak.adapters.authentication.ClientCredentialsProviderUtils;
|
import org.keycloak.adapters.authentication.ClientCredentialsProviderUtils;
|
||||||
import org.keycloak.constants.ServiceUrlConstants;
|
import org.keycloak.constants.ServiceUrlConstants;
|
||||||
import org.keycloak.representations.AccessTokenResponse;
|
import org.keycloak.representations.AccessTokenResponse;
|
||||||
|
import org.keycloak.representations.idm.OAuth2ErrorRepresentation;
|
||||||
import org.keycloak.util.JsonSerialization;
|
import org.keycloak.util.JsonSerialization;
|
||||||
import org.keycloak.common.util.KeycloakUriBuilder;
|
import org.keycloak.common.util.KeycloakUriBuilder;
|
||||||
|
|
||||||
@@ -102,9 +103,9 @@ public class DirectAccessGrantsLoginModule extends AbstractKeycloakLoginModule {
|
|||||||
StringBuilder errorBuilder = new StringBuilder("Login failed. Invalid status: " + status);
|
StringBuilder errorBuilder = new StringBuilder("Login failed. Invalid status: " + status);
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
InputStream is = entity.getContent();
|
InputStream is = entity.getContent();
|
||||||
Map<String, String> errors = (Map<String, String>) JsonSerialization.readValue(is, Map.class);
|
OAuth2ErrorRepresentation errorRep = JsonSerialization.readValue(is, OAuth2ErrorRepresentation.class);
|
||||||
errorBuilder.append(", OAuth2 error. Error: " + errors.get(OAuth2Constants.ERROR))
|
errorBuilder.append(", OAuth2 error. Error: " + errorRep.getError())
|
||||||
.append(", Error description: " + errors.get(OAuth2Constants.ERROR_DESCRIPTION));
|
.append(", Error description: " + errorRep.getErrorDescription());
|
||||||
}
|
}
|
||||||
String error = errorBuilder.toString();
|
String error = errorBuilder.toString();
|
||||||
log.warn(error);
|
log.warn(error);
|
||||||
@@ -161,9 +162,9 @@ public class DirectAccessGrantsLoginModule extends AbstractKeycloakLoginModule {
|
|||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
InputStream is = entity.getContent();
|
InputStream is = entity.getContent();
|
||||||
if (status == 400) {
|
if (status == 400) {
|
||||||
Map<String, String> errors = (Map<String, String>) JsonSerialization.readValue(is, Map.class);
|
OAuth2ErrorRepresentation errorRep = JsonSerialization.readValue(is, OAuth2ErrorRepresentation.class);
|
||||||
errorBuilder.append(", OAuth2 error. Error: " + errors.get(OAuth2Constants.ERROR))
|
errorBuilder.append(", OAuth2 error. Error: " + errorRep.getError())
|
||||||
.append(", Error description: " + errors.get(OAuth2Constants.ERROR_DESCRIPTION));
|
.append(", Error description: " + errorRep.getErrorDescription());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (is != null) is.close();
|
if (is != null) is.close();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-as7-integration-pom</artifactId>
|
<artifactId>keycloak-as7-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-as7-integration-pom</artifactId>
|
<artifactId>keycloak-as7-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<artifactId>keycloak-as7-integration-pom</artifactId>
|
<artifactId>keycloak-as7-integration-pom</artifactId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
+6
-7
@@ -49,7 +49,6 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
@Override
|
@Override
|
||||||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
||||||
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
String deploymentName = deploymentUnit.getName();
|
|
||||||
|
|
||||||
// if it's not a web-app there's nothing to secure
|
// if it's not a web-app there's nothing to secure
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
@@ -67,24 +66,24 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
// otherwise
|
// otherwise
|
||||||
LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
|
LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
|
||||||
|
|
||||||
boolean hasSubsystemConfig = service.isSecureDeployment(deploymentName);
|
boolean hasSubsystemConfig = service.isSecureDeployment(deploymentUnit);
|
||||||
boolean webRequiresKC = loginConfig != null && "KEYCLOAK".equalsIgnoreCase(loginConfig.getAuthMethod());
|
boolean webRequiresKC = loginConfig != null && "KEYCLOAK".equalsIgnoreCase(loginConfig.getAuthMethod());
|
||||||
|
|
||||||
if (hasSubsystemConfig || webRequiresKC) {
|
if (hasSubsystemConfig || webRequiresKC) {
|
||||||
log.debug("Setting up KEYCLOAK auth method for WAR: " + deploymentName);
|
log.debug("Setting up KEYCLOAK auth method for WAR: " + deploymentUnit.getName());
|
||||||
|
|
||||||
// if secure-deployment configuration exists for web app, we force KEYCLOAK auth method on it
|
// if secure-deployment configuration exists for web app, we force KEYCLOAK auth method on it
|
||||||
if (hasSubsystemConfig) {
|
if (hasSubsystemConfig) {
|
||||||
addJSONData(service.getJSON(deploymentName), warMetaData);
|
addJSONData(service.getJSON(deploymentUnit), warMetaData);
|
||||||
if (loginConfig != null) {
|
if (loginConfig != null) {
|
||||||
loginConfig.setAuthMethod("KEYCLOAK");
|
loginConfig.setAuthMethod("KEYCLOAK");
|
||||||
loginConfig.setRealmName(service.getRealmName(deploymentName));
|
loginConfig.setRealmName(service.getRealmName(deploymentUnit));
|
||||||
} else {
|
} else {
|
||||||
log.warn("Failed to set up KEYCLOAK auth method for WAR: " + deploymentName + " (loginConfig == null)");
|
log.warn("Failed to set up KEYCLOAK auth method for WAR: " + deploymentUnit.getName() + " (loginConfig == null)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addValve(webMetaData);
|
addValve(webMetaData);
|
||||||
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentName);
|
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentUnit.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+28
-3
@@ -25,6 +25,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
|
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
|
||||||
|
import org.jboss.as.server.deployment.DeploymentUnit;
|
||||||
|
import org.jboss.as.web.deployment.WarMetaData;
|
||||||
|
import org.jboss.metadata.web.jboss.JBossWebMetaData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service keeps track of the entire Keycloak management model so as to provide
|
* This service keeps track of the entire Keycloak management model so as to provide
|
||||||
@@ -154,13 +157,15 @@ public final class KeycloakAdapterConfigService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRealmName(String deploymentName) {
|
public String getRealmName(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
||||||
return deployment.get(RealmDefinition.TAG_NAME).asString();
|
return deployment.get(RealmDefinition.TAG_NAME).asString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJSON(String deploymentName) {
|
public String getJSON(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
||||||
String realmName = deployment.get(RealmDefinition.TAG_NAME).asString();
|
String realmName = deployment.get(RealmDefinition.TAG_NAME).asString();
|
||||||
ModelNode realm = this.realms.get(realmName);
|
ModelNode realm = this.realms.get(realmName);
|
||||||
@@ -184,9 +189,29 @@ public final class KeycloakAdapterConfigService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSecureDeployment(String deploymentName) {
|
public boolean isSecureDeployment(DeploymentUnit deploymentUnit) {
|
||||||
//log.info("********* CHECK KEYCLOAK DEPLOYMENT: deployments.size()" + deployments.size());
|
//log.info("********* CHECK KEYCLOAK DEPLOYMENT: deployments.size()" + deployments.size());
|
||||||
|
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
return this.secureDeployments.containsKey(deploymentName);
|
return this.secureDeployments.containsKey(deploymentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KEYCLOAK-3273: prefer module name if available
|
||||||
|
private String preferredDeploymentName(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = deploymentUnit.getName();
|
||||||
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
|
if (warMetaData == null) {
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
|
||||||
|
if (webMetaData == null) {
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String moduleName = webMetaData.getModuleName();
|
||||||
|
if (moduleName != null) return moduleName + ".war";
|
||||||
|
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -46,8 +46,7 @@ public abstract class KeycloakDependencyProcessor implements DeploymentUnitProce
|
|||||||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
||||||
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
|
|
||||||
String deploymentName = deploymentUnit.getName();
|
if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentUnit)) {
|
||||||
if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentName)) {
|
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
if (warMetaData == null) {
|
if (warMetaData == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak AS7 / JBoss EAP 6 Integration</name>
|
<name>Keycloak AS7 / JBoss EAP 6 Integration</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+2
@@ -119,6 +119,7 @@ public class KeycloakInstalled {
|
|||||||
.queryParam(OAuth2Constants.CLIENT_ID, deployment.getResourceName())
|
.queryParam(OAuth2Constants.CLIENT_ID, deployment.getResourceName())
|
||||||
.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri)
|
.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri)
|
||||||
.queryParam(OAuth2Constants.STATE, state)
|
.queryParam(OAuth2Constants.STATE, state)
|
||||||
|
.queryParam(OAuth2Constants.SCOPE, OAuth2Constants.SCOPE_OPENID)
|
||||||
.build().toString();
|
.build().toString();
|
||||||
|
|
||||||
Desktop.getDesktop().browse(new URI(authUrl));
|
Desktop.getDesktop().browse(new URI(authUrl));
|
||||||
@@ -175,6 +176,7 @@ public class KeycloakInstalled {
|
|||||||
.queryParam(OAuth2Constants.RESPONSE_TYPE, OAuth2Constants.CODE)
|
.queryParam(OAuth2Constants.RESPONSE_TYPE, OAuth2Constants.CODE)
|
||||||
.queryParam(OAuth2Constants.CLIENT_ID, deployment.getResourceName())
|
.queryParam(OAuth2Constants.CLIENT_ID, deployment.getResourceName())
|
||||||
.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri)
|
.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri)
|
||||||
|
.queryParam(OAuth2Constants.SCOPE, OAuth2Constants.SCOPE_OPENID)
|
||||||
.build().toString();
|
.build().toString();
|
||||||
|
|
||||||
printer.println("Open the following URL in a browser. After login copy/paste the code back and press <enter>");
|
printer.println("Open the following URL in a browser. After login copy/paste the code back and press <enter>");
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+4
-4
@@ -20,6 +20,7 @@ package org.keycloak.jaxrs;
|
|||||||
import org.keycloak.AbstractOAuthClient;
|
import org.keycloak.AbstractOAuthClient;
|
||||||
import org.keycloak.OAuth2Constants;
|
import org.keycloak.OAuth2Constants;
|
||||||
import org.keycloak.representations.AccessTokenResponse;
|
import org.keycloak.representations.AccessTokenResponse;
|
||||||
|
import org.keycloak.util.TokenUtil;
|
||||||
|
|
||||||
import javax.ws.rs.BadRequestException;
|
import javax.ws.rs.BadRequestException;
|
||||||
import javax.ws.rs.InternalServerErrorException;
|
import javax.ws.rs.InternalServerErrorException;
|
||||||
@@ -85,14 +86,13 @@ public class JaxrsOAuthClient extends AbstractOAuthClient {
|
|||||||
}
|
}
|
||||||
public Response redirect(UriInfo uriInfo, String redirectUri) {
|
public Response redirect(UriInfo uriInfo, String redirectUri) {
|
||||||
String state = getStateCode();
|
String state = getStateCode();
|
||||||
|
String scopeParam = TokenUtil.attachOIDCScope(scope);
|
||||||
|
|
||||||
UriBuilder uriBuilder = UriBuilder.fromUri(authUrl)
|
UriBuilder uriBuilder = UriBuilder.fromUri(authUrl)
|
||||||
.queryParam(OAuth2Constants.CLIENT_ID, clientId)
|
.queryParam(OAuth2Constants.CLIENT_ID, clientId)
|
||||||
.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri)
|
.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri)
|
||||||
.queryParam(OAuth2Constants.STATE, state);
|
.queryParam(OAuth2Constants.STATE, state)
|
||||||
if (scope != null) {
|
.queryParam(OAuth2Constants.SCOPE, scopeParam);
|
||||||
uriBuilder.queryParam(OAuth2Constants.SCOPE, scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
URI url = uriBuilder.build();
|
URI url = uriBuilder.build();
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+2
-2
@@ -340,13 +340,13 @@ public abstract class AbstractKeycloakJettyAuthenticator extends LoginAuthentica
|
|||||||
Authentication authentication = request.getAuthentication();
|
Authentication authentication = request.getAuthentication();
|
||||||
if (!(authentication instanceof KeycloakAuthentication)) {
|
if (!(authentication instanceof KeycloakAuthentication)) {
|
||||||
UserIdentity userIdentity = createIdentity(principal);
|
UserIdentity userIdentity = createIdentity(principal);
|
||||||
authentication = createAuthentication(userIdentity);
|
authentication = createAuthentication(userIdentity, request);
|
||||||
request.setAuthentication(authentication);
|
request.setAuthentication(authentication);
|
||||||
}
|
}
|
||||||
return authentication;
|
return authentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Authentication createAuthentication(UserIdentity userIdentity);
|
protected abstract Authentication createAuthentication(UserIdentity userIdentity, Request request);
|
||||||
|
|
||||||
public static abstract class KeycloakAuthentication extends UserAuthentication {
|
public static abstract class KeycloakAuthentication extends UserAuthentication {
|
||||||
public KeycloakAuthentication(String method, UserIdentity userIdentity) {
|
public KeycloakAuthentication(String method, UserIdentity userIdentity) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ public class KeycloakJettyAuthenticator extends AbstractKeycloakJettyAuthenticat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Authentication createAuthentication(UserIdentity userIdentity) {
|
protected Authentication createAuthentication(UserIdentity userIdentity, Request request) {
|
||||||
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
||||||
@Override
|
@Override
|
||||||
public void logout() {
|
public void logout() {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ public class KeycloakJettyAuthenticator extends AbstractKeycloakJettyAuthenticat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Authentication createAuthentication(UserIdentity userIdentity) {
|
protected Authentication createAuthentication(UserIdentity userIdentity, Request request) {
|
||||||
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
||||||
@Override
|
@Override
|
||||||
public void logout() {
|
public void logout() {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ public class KeycloakJettyAuthenticator extends AbstractKeycloakJettyAuthenticat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Authentication createAuthentication(UserIdentity userIdentity) {
|
protected Authentication createAuthentication(UserIdentity userIdentity, Request request) {
|
||||||
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
||||||
@Override
|
@Override
|
||||||
public void logout() {
|
public void logout() {
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
~ and other contributors as indicated by the @author tags.
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>keycloak-parent</artifactId>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<version>2.2.1.Final</version>
|
||||||
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>keycloak-jetty93-adapter</artifactId>
|
||||||
|
<name>Keycloak Jetty 9.3.x Integration</name>
|
||||||
|
<properties>
|
||||||
|
<jetty9.version>9.3.9.v20160517</jetty9.version>
|
||||||
|
<keycloak.osgi.export>
|
||||||
|
org.keycloak.adapters.jetty.*
|
||||||
|
</keycloak.osgi.export>
|
||||||
|
<keycloak.osgi.import>
|
||||||
|
org.eclipse.jetty.*;resolution:=optional,
|
||||||
|
javax.servlet.*;version="[3.0,4)";resolution:=optional,
|
||||||
|
org.keycloak.*;version="${project.version}",
|
||||||
|
*;resolution:=optional
|
||||||
|
</keycloak.osgi.import>
|
||||||
|
</properties>
|
||||||
|
<description />
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.logging</groupId>
|
||||||
|
<artifactId>jboss-logging</artifactId>
|
||||||
|
<version>${jboss.logging.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-adapter-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-jetty-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-server</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-util</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-security</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Adding OSGI metadata to the JAR without changing the packaging type. -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>bundle-manifest</id>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>manifest</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-ClassPath>.</Bundle-ClassPath>
|
||||||
|
<Bundle-Name>${project.name}</Bundle-Name>
|
||||||
|
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Import-Package>${keycloak.osgi.import}</Import-Package>
|
||||||
|
<Export-Package>${keycloak.osgi.export}</Export-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.adapters.jetty;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.Request;
|
||||||
|
import org.keycloak.adapters.AdapterTokenStore;
|
||||||
|
import org.keycloak.adapters.KeycloakDeployment;
|
||||||
|
import org.keycloak.adapters.jetty.core.JettyRequestAuthenticator;
|
||||||
|
import org.keycloak.adapters.spi.HttpFacade;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class Jetty93RequestAuthenticator extends JettyRequestAuthenticator {
|
||||||
|
public Jetty93RequestAuthenticator(HttpFacade facade, KeycloakDeployment deployment, AdapterTokenStore tokenStore, int sslRedirectPort, Request request) {
|
||||||
|
super(facade, deployment, tokenStore, sslRedirectPort, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String changeHttpSessionId(boolean create) {
|
||||||
|
Request request = this.request;
|
||||||
|
HttpSession session = request.getSession(false);
|
||||||
|
if (session == null) {
|
||||||
|
return request.getSession(true).getId();
|
||||||
|
}
|
||||||
|
if (!deployment.isTurnOffChangeSessionIdOnLogin()) return request.changeSessionId();
|
||||||
|
else return session.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.adapters.jetty;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
|
import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
||||||
|
import org.eclipse.jetty.server.Request;
|
||||||
|
import org.eclipse.jetty.util.MultiMap;
|
||||||
|
import org.keycloak.adapters.spi.AdapterSessionStore;
|
||||||
|
import org.keycloak.adapters.jetty.spi.JettyHttpFacade;
|
||||||
|
import org.keycloak.common.util.MultivaluedHashMap;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class JettyAdapterSessionStore implements AdapterSessionStore {
|
||||||
|
public static final String CACHED_FORM_PARAMETERS = "__CACHED_FORM_PARAMETERS";
|
||||||
|
protected Request myRequest;
|
||||||
|
|
||||||
|
public JettyAdapterSessionStore(Request request) {
|
||||||
|
this.myRequest = request; // for IDE/compilation purposes
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MultiMap<String> extractFormParameters(Request base_request) {
|
||||||
|
MultiMap<String> formParameters = new MultiMap<String>();
|
||||||
|
base_request.extractFormParameters(formParameters);
|
||||||
|
return formParameters;
|
||||||
|
}
|
||||||
|
protected void restoreFormParameters(MultiMap<String> j_post, Request base_request) {
|
||||||
|
base_request.setContentParameters(j_post);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean restoreRequest() {
|
||||||
|
HttpSession session = myRequest.getSession(false);
|
||||||
|
if (session == null) return false;
|
||||||
|
synchronized (session) {
|
||||||
|
String j_uri = (String) session.getAttribute(FormAuthenticator.__J_URI);
|
||||||
|
if (j_uri != null) {
|
||||||
|
// check if the request is for the same url as the original and restore
|
||||||
|
// params if it was a post
|
||||||
|
StringBuffer buf = myRequest.getRequestURL();
|
||||||
|
if (myRequest.getQueryString() != null)
|
||||||
|
buf.append("?").append(myRequest.getQueryString());
|
||||||
|
if (j_uri.equals(buf.toString())) {
|
||||||
|
String method = (String)session.getAttribute(JettyHttpFacade.__J_METHOD);
|
||||||
|
myRequest.setMethod(method);
|
||||||
|
MultivaluedHashMap<String, String> j_post = (MultivaluedHashMap<String, String>) session.getAttribute(CACHED_FORM_PARAMETERS);
|
||||||
|
if (j_post != null) {
|
||||||
|
myRequest.setContentType("application/x-www-form-urlencoded");
|
||||||
|
MultiMap<String> map = new MultiMap<String>();
|
||||||
|
for (String key : j_post.keySet()) {
|
||||||
|
for (String val : j_post.getList(key)) {
|
||||||
|
map.add(key, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
restoreFormParameters(map, myRequest);
|
||||||
|
}
|
||||||
|
session.removeAttribute(FormAuthenticator.__J_URI);
|
||||||
|
session.removeAttribute(JettyHttpFacade.__J_METHOD);
|
||||||
|
session.removeAttribute(FormAuthenticator.__J_POST);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveRequest() {
|
||||||
|
// remember the current URI
|
||||||
|
HttpSession session = myRequest.getSession();
|
||||||
|
synchronized (session) {
|
||||||
|
// But only if it is not set already, or we save every uri that leads to a login form redirect
|
||||||
|
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
|
||||||
|
StringBuffer buf = myRequest.getRequestURL();
|
||||||
|
if (myRequest.getQueryString() != null)
|
||||||
|
buf.append("?").append(myRequest.getQueryString());
|
||||||
|
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
|
||||||
|
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
|
||||||
|
|
||||||
|
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
|
||||||
|
MultiMap<String> formParameters = extractFormParameters(myRequest);
|
||||||
|
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
|
||||||
|
for (String key : formParameters.keySet()) {
|
||||||
|
for (Object value : formParameters.getValues(key)) {
|
||||||
|
map.add(key, (String) value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.setAttribute(CACHED_FORM_PARAMETERS, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.adapters.jetty;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.Authentication;
|
||||||
|
import org.eclipse.jetty.server.Request;
|
||||||
|
import org.eclipse.jetty.server.UserIdentity;
|
||||||
|
import org.keycloak.adapters.AdapterTokenStore;
|
||||||
|
import org.keycloak.adapters.KeycloakDeployment;
|
||||||
|
import org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator;
|
||||||
|
import org.keycloak.adapters.jetty.core.JettyRequestAuthenticator;
|
||||||
|
import org.keycloak.adapters.jetty.core.JettySessionTokenStore;
|
||||||
|
import org.keycloak.adapters.jetty.spi.JettyHttpFacade;
|
||||||
|
|
||||||
|
import javax.servlet.ServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class KeycloakJettyAuthenticator extends AbstractKeycloakJettyAuthenticator {
|
||||||
|
|
||||||
|
public KeycloakJettyAuthenticator() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Request resolveRequest(ServletRequest req) {
|
||||||
|
return Request.getBaseRequest(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Authentication createAuthentication(UserIdentity userIdentity, final Request request) {
|
||||||
|
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
||||||
|
@Override
|
||||||
|
public void logout() {
|
||||||
|
logoutCurrent(request);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AdapterTokenStore createSessionTokenStore(Request request, KeycloakDeployment resolvedDeployment) {
|
||||||
|
return new JettySessionTokenStore(request, resolvedDeployment, new JettyAdapterSessionStore(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JettyRequestAuthenticator createRequestAuthenticator(Request request, JettyHttpFacade facade,
|
||||||
|
KeycloakDeployment deployment, AdapterTokenStore tokenStore) {
|
||||||
|
return new Jetty93RequestAuthenticator(facade, deployment, tokenStore, -1, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak Jetty Integration</name>
|
<name>Keycloak Jetty Integration</name>
|
||||||
@@ -33,7 +33,8 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>jetty-core</module>
|
<module>jetty-core</module>
|
||||||
<module>jetty8.1</module>
|
<module>jetty8.1</module>
|
||||||
<module>jetty9.2</module>
|
|
||||||
<module>jetty9.1</module>
|
<module>jetty9.1</module>
|
||||||
|
<module>jetty9.2</module>
|
||||||
|
<module>jetty9.3</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
*/
|
*/
|
||||||
this.authorize = function (wwwAuthenticateHeader) {
|
this.authorize = function (wwwAuthenticateHeader) {
|
||||||
this.then = function (onGrant, onDeny, onError) {
|
this.then = function (onGrant, onDeny, onError) {
|
||||||
if (wwwAuthenticateHeader.startsWith('UMA')) {
|
if (wwwAuthenticateHeader.indexOf('UMA') != -1) {
|
||||||
var params = wwwAuthenticateHeader.split(',');
|
var params = wwwAuthenticateHeader.split(',');
|
||||||
|
|
||||||
for (i = 0; i < params.length; i++) {
|
for (i = 0; i < params.length; i++) {
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (wwwAuthenticateHeader.startsWith('KC_ETT')) {
|
} else if (wwwAuthenticateHeader.indexOf('KC_ETT') != -1) {
|
||||||
var params = wwwAuthenticateHeader.substring('KC_ETT'.length).trim().split(',');
|
var params = wwwAuthenticateHeader.substring('KC_ETT'.length).trim().split(',');
|
||||||
var clientId = null;
|
var clientId = null;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
var kc = this;
|
var kc = this;
|
||||||
var adapter;
|
var adapter;
|
||||||
var refreshQueue = [];
|
var refreshQueue = [];
|
||||||
var storage;
|
var callbackStorage;
|
||||||
|
|
||||||
var loginIframe = {
|
var loginIframe = {
|
||||||
enable: true,
|
enable: true,
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
kc.init = function (initOptions) {
|
kc.init = function (initOptions) {
|
||||||
kc.authenticated = false;
|
kc.authenticated = false;
|
||||||
|
|
||||||
storage = new PersistentStorage();
|
callbackStorage = createCallbackStorage();
|
||||||
|
|
||||||
if (initOptions && initOptions.adapter === 'cordova') {
|
if (initOptions && initOptions.adapter === 'cordova') {
|
||||||
adapter = loadAdapter('cordova');
|
adapter = loadAdapter('cordova');
|
||||||
@@ -103,8 +103,8 @@
|
|||||||
initPromise.promise.success(function() {
|
initPromise.promise.success(function() {
|
||||||
kc.onReady && kc.onReady(kc.authenticated);
|
kc.onReady && kc.onReady(kc.authenticated);
|
||||||
promise.setSuccess(kc.authenticated);
|
promise.setSuccess(kc.authenticated);
|
||||||
}).error(function() {
|
}).error(function(errorData) {
|
||||||
promise.setError();
|
promise.setError(errorData);
|
||||||
});
|
});
|
||||||
|
|
||||||
var configPromise = loadConfig(config);
|
var configPromise = loadConfig(config);
|
||||||
@@ -154,21 +154,30 @@
|
|||||||
return;
|
return;
|
||||||
} else if (initOptions) {
|
} else if (initOptions) {
|
||||||
if (initOptions.token || initOptions.refreshToken) {
|
if (initOptions.token || initOptions.refreshToken) {
|
||||||
setToken(initOptions.token, initOptions.refreshToken, initOptions.idToken, false);
|
setToken(initOptions.token, initOptions.refreshToken, initOptions.idToken);
|
||||||
kc.timeSkew = initOptions.timeSkew || 0;
|
|
||||||
|
|
||||||
if (loginIframe.enable) {
|
if (loginIframe.enable) {
|
||||||
setupCheckLoginIframe().success(function() {
|
setupCheckLoginIframe().success(function() {
|
||||||
checkLoginIframe().success(function () {
|
checkLoginIframe().success(function () {
|
||||||
|
kc.onAuthSuccess && kc.onAuthSuccess();
|
||||||
initPromise.setSuccess();
|
initPromise.setSuccess();
|
||||||
}).error(function () {
|
}).error(function () {
|
||||||
|
kc.onAuthError && kc.onAuthError();
|
||||||
if (initOptions.onLoad) {
|
if (initOptions.onLoad) {
|
||||||
onLoad();
|
onLoad();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
kc.updateToken(-1).success(function() {
|
||||||
|
kc.onAuthSuccess && kc.onAuthSuccess();
|
||||||
initPromise.setSuccess();
|
initPromise.setSuccess();
|
||||||
|
}).error(function() {
|
||||||
|
kc.onAuthError && kc.onAuthError();
|
||||||
|
if (initOptions.onLoad) {
|
||||||
|
onLoad();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (initOptions.onLoad) {
|
} else if (initOptions.onLoad) {
|
||||||
onLoad();
|
onLoad();
|
||||||
@@ -201,13 +210,15 @@
|
|||||||
redirectUri += (redirectUri.indexOf('?') == -1 ? '?' : '&') + 'prompt=' + options.prompt;
|
redirectUri += (redirectUri.indexOf('?') == -1 ? '?' : '&') + 'prompt=' + options.prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.setItem('oauthState', JSON.stringify({ state: state, nonce: nonce, redirectUri: encodeURIComponent(redirectUri) }));
|
callbackStorage.add({ state: state, nonce: nonce, redirectUri: encodeURIComponent(redirectUri) });
|
||||||
|
|
||||||
var action = 'auth';
|
var action = 'auth';
|
||||||
if (options && options.action == 'register') {
|
if (options && options.action == 'register') {
|
||||||
action = 'registrations';
|
action = 'registrations';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var scope = (options && options.scope) ? "openid " + options.scope : "openid";
|
||||||
|
|
||||||
var url = getRealmUrl()
|
var url = getRealmUrl()
|
||||||
+ '/protocol/openid-connect/' + action
|
+ '/protocol/openid-connect/' + action
|
||||||
+ '?client_id=' + encodeURIComponent(kc.clientId)
|
+ '?client_id=' + encodeURIComponent(kc.clientId)
|
||||||
@@ -215,12 +226,17 @@
|
|||||||
+ '&state=' + encodeURIComponent(state)
|
+ '&state=' + encodeURIComponent(state)
|
||||||
+ '&nonce=' + encodeURIComponent(nonce)
|
+ '&nonce=' + encodeURIComponent(nonce)
|
||||||
+ '&response_mode=' + encodeURIComponent(kc.responseMode)
|
+ '&response_mode=' + encodeURIComponent(kc.responseMode)
|
||||||
+ '&response_type=' + encodeURIComponent(kc.responseType);
|
+ '&response_type=' + encodeURIComponent(kc.responseType)
|
||||||
|
+ '&scope=' + encodeURIComponent(scope);
|
||||||
|
|
||||||
if (options && options.prompt) {
|
if (options && options.prompt) {
|
||||||
url += '&prompt=' + encodeURIComponent(options.prompt);
|
url += '&prompt=' + encodeURIComponent(options.prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options && options.maxAge) {
|
||||||
|
url += '&max_age=' + encodeURIComponent(options.maxAge);
|
||||||
|
}
|
||||||
|
|
||||||
if (options && options.loginHint) {
|
if (options && options.loginHint) {
|
||||||
url += '&login_hint=' + encodeURIComponent(options.loginHint);
|
url += '&login_hint=' + encodeURIComponent(options.loginHint);
|
||||||
}
|
}
|
||||||
@@ -229,10 +245,6 @@
|
|||||||
url += '&kc_idp_hint=' + encodeURIComponent(options.idpHint);
|
url += '&kc_idp_hint=' + encodeURIComponent(options.idpHint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options && options.scope) {
|
|
||||||
url += '&scope=' + encodeURIComponent(options.scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options && options.locale) {
|
if (options && options.locale) {
|
||||||
url += '&ui_locales=' + encodeURIComponent(options.locale);
|
url += '&ui_locales=' + encodeURIComponent(options.locale);
|
||||||
}
|
}
|
||||||
@@ -346,11 +358,10 @@
|
|||||||
throw 'Not authenticated';
|
throw 'Not authenticated';
|
||||||
}
|
}
|
||||||
|
|
||||||
var expiresIn = kc.tokenParsed['exp'] - (new Date().getTime() / 1000) + kc.timeSkew;
|
var expiresIn = kc.tokenParsed['exp'] - Math.ceil(new Date().getTime() / 1000) + kc.timeSkew;
|
||||||
if (minValidity) {
|
if (minValidity) {
|
||||||
expiresIn -= minValidity;
|
expiresIn -= minValidity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return expiresIn < 0;
|
return expiresIn < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +376,20 @@
|
|||||||
minValidity = minValidity || 5;
|
minValidity = minValidity || 5;
|
||||||
|
|
||||||
var exec = function() {
|
var exec = function() {
|
||||||
if (!kc.isTokenExpired(minValidity)) {
|
var refreshToken = false;
|
||||||
|
if (kc.timeSkew == -1) {
|
||||||
|
console.info('Skew ' + kc.timeSkew);
|
||||||
|
refreshToken = true;
|
||||||
|
console.info('[KEYCLOAK] Refreshing token: time skew not set');
|
||||||
|
} else if (minValidity == -1) {
|
||||||
|
refreshToken = true;
|
||||||
|
console.info('[KEYCLOAK] Refreshing token: forced refresh');
|
||||||
|
} else if (kc.isTokenExpired(minValidity)) {
|
||||||
|
refreshToken = true;
|
||||||
|
console.info('[KEYCLOAK] Refreshing token: token expired');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!refreshToken) {
|
||||||
promise.setSuccess(false);
|
promise.setSuccess(false);
|
||||||
} else {
|
} else {
|
||||||
var params = 'grant_type=refresh_token&' + 'refresh_token=' + kc.refreshToken;
|
var params = 'grant_type=refresh_token&' + 'refresh_token=' + kc.refreshToken;
|
||||||
@@ -377,6 +401,7 @@
|
|||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
req.open('POST', url, true);
|
req.open('POST', url, true);
|
||||||
req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
req.withCredentials = true;
|
||||||
|
|
||||||
if (kc.clientId && kc.clientSecret) {
|
if (kc.clientId && kc.clientSecret) {
|
||||||
req.setRequestHeader('Authorization', 'Basic ' + btoa(kc.clientId + ':' + kc.clientSecret));
|
req.setRequestHeader('Authorization', 'Basic ' + btoa(kc.clientId + ':' + kc.clientSecret));
|
||||||
@@ -389,18 +414,21 @@
|
|||||||
req.onreadystatechange = function () {
|
req.onreadystatechange = function () {
|
||||||
if (req.readyState == 4) {
|
if (req.readyState == 4) {
|
||||||
if (req.status == 200) {
|
if (req.status == 200) {
|
||||||
|
console.info('[KEYCLOAK] Token refreshed');
|
||||||
|
|
||||||
timeLocal = (timeLocal + new Date().getTime()) / 2;
|
timeLocal = (timeLocal + new Date().getTime()) / 2;
|
||||||
|
|
||||||
var tokenResponse = JSON.parse(req.responseText);
|
var tokenResponse = JSON.parse(req.responseText);
|
||||||
setToken(tokenResponse['access_token'], tokenResponse['refresh_token'], tokenResponse['id_token'], true);
|
|
||||||
|
|
||||||
kc.timeSkew = Math.floor(timeLocal / 1000) - kc.tokenParsed.iat;
|
setToken(tokenResponse['access_token'], tokenResponse['refresh_token'], tokenResponse['id_token'], timeLocal);
|
||||||
|
|
||||||
kc.onAuthRefreshSuccess && kc.onAuthRefreshSuccess();
|
kc.onAuthRefreshSuccess && kc.onAuthRefreshSuccess();
|
||||||
for (var p = refreshQueue.pop(); p != null; p = refreshQueue.pop()) {
|
for (var p = refreshQueue.pop(); p != null; p = refreshQueue.pop()) {
|
||||||
p.setSuccess(true);
|
p.setSuccess(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
console.warn('[KEYCLOAK] Failed to refresh token');
|
||||||
|
|
||||||
kc.onAuthRefreshError && kc.onAuthRefreshError();
|
kc.onAuthRefreshError && kc.onAuthRefreshError();
|
||||||
for (var p = refreshQueue.pop(); p != null; p = refreshQueue.pop()) {
|
for (var p = refreshQueue.pop(); p != null; p = refreshQueue.pop()) {
|
||||||
p.setError(true);
|
p.setError(true);
|
||||||
@@ -430,7 +458,7 @@
|
|||||||
|
|
||||||
kc.clearToken = function() {
|
kc.clearToken = function() {
|
||||||
if (kc.token) {
|
if (kc.token) {
|
||||||
setToken(null, null, null, true);
|
setToken(null, null, null);
|
||||||
kc.onAuthLogout && kc.onAuthLogout();
|
kc.onAuthLogout && kc.onAuthLogout();
|
||||||
if (kc.loginRequired) {
|
if (kc.loginRequired) {
|
||||||
kc.login();
|
kc.login();
|
||||||
@@ -463,8 +491,9 @@
|
|||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (prompt != 'none') {
|
if (prompt != 'none') {
|
||||||
kc.onAuthError && kc.onAuthError();
|
var errorData = { error: error, error_description: oauth.error_description };
|
||||||
promise && promise.setError();
|
kc.onAuthError && kc.onAuthError(errorData);
|
||||||
|
promise && promise.setError(errorData);
|
||||||
} else {
|
} else {
|
||||||
promise && promise.setSuccess();
|
promise && promise.setSuccess();
|
||||||
}
|
}
|
||||||
@@ -510,18 +539,16 @@
|
|||||||
function authSuccess(accessToken, refreshToken, idToken, fulfillPromise) {
|
function authSuccess(accessToken, refreshToken, idToken, fulfillPromise) {
|
||||||
timeLocal = (timeLocal + new Date().getTime()) / 2;
|
timeLocal = (timeLocal + new Date().getTime()) / 2;
|
||||||
|
|
||||||
setToken(accessToken, refreshToken, idToken, true);
|
setToken(accessToken, refreshToken, idToken, timeLocal);
|
||||||
|
|
||||||
if ((kc.tokenParsed && kc.tokenParsed.nonce != oauth.storedNonce) ||
|
if ((kc.tokenParsed && kc.tokenParsed.nonce != oauth.storedNonce) ||
|
||||||
(kc.refreshTokenParsed && kc.refreshTokenParsed.nonce != oauth.storedNonce) ||
|
(kc.refreshTokenParsed && kc.refreshTokenParsed.nonce != oauth.storedNonce) ||
|
||||||
(kc.idTokenParsed && kc.idTokenParsed.nonce != oauth.storedNonce)) {
|
(kc.idTokenParsed && kc.idTokenParsed.nonce != oauth.storedNonce)) {
|
||||||
|
|
||||||
console.log('invalid nonce!');
|
console.info('[KEYCLOAK] Invalid nonce, clearing token');
|
||||||
kc.clearToken();
|
kc.clearToken();
|
||||||
promise && promise.setError();
|
promise && promise.setError();
|
||||||
} else {
|
} else {
|
||||||
kc.timeSkew = Math.floor(timeLocal / 1000) - kc.tokenParsed.iat;
|
|
||||||
|
|
||||||
if (fulfillPromise) {
|
if (fulfillPromise) {
|
||||||
kc.onAuthSuccess && kc.onAuthSuccess();
|
kc.onAuthSuccess && kc.onAuthSuccess();
|
||||||
promise && promise.setSuccess();
|
promise && promise.setSuccess();
|
||||||
@@ -594,7 +621,7 @@
|
|||||||
return promise.promise;
|
return promise.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setToken(token, refreshToken, idToken, useTokenTime) {
|
function setToken(token, refreshToken, idToken, timeLocal) {
|
||||||
if (kc.tokenTimeoutHandle) {
|
if (kc.tokenTimeoutHandle) {
|
||||||
clearTimeout(kc.tokenTimeoutHandle);
|
clearTimeout(kc.tokenTimeoutHandle);
|
||||||
kc.tokenTimeoutHandle = null;
|
kc.tokenTimeoutHandle = null;
|
||||||
@@ -613,10 +640,24 @@
|
|||||||
kc.realmAccess = kc.tokenParsed.realm_access;
|
kc.realmAccess = kc.tokenParsed.realm_access;
|
||||||
kc.resourceAccess = kc.tokenParsed.resource_access;
|
kc.resourceAccess = kc.tokenParsed.resource_access;
|
||||||
|
|
||||||
|
if (timeLocal) {
|
||||||
|
kc.timeSkew = Math.floor(timeLocal / 1000) - kc.tokenParsed.iat;
|
||||||
|
console.info('[KEYCLOAK] Estimated time difference between browser and server is ' + kc.timeSkew + ' seconds');
|
||||||
|
} else {
|
||||||
|
kc.timeSkew = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (kc.onTokenExpired) {
|
if (kc.onTokenExpired) {
|
||||||
var start = useTokenTime ? kc.tokenParsed.iat : (new Date().getTime() / 1000);
|
if (kc.timeSkew == -1) {
|
||||||
var expiresIn = kc.tokenParsed.exp - start;
|
kc.onTokenExpired();
|
||||||
kc.tokenTimeoutHandle = setTimeout(kc.onTokenExpired, expiresIn * 1000);
|
} else {
|
||||||
|
var expiresIn = (kc.tokenParsed['exp'] - (new Date().getTime() / 1000) + kc.timeSkew) * 1000;
|
||||||
|
if (expiresIn <= 0) {
|
||||||
|
kc.onTokenExpired();
|
||||||
|
} else {
|
||||||
|
kc.tokenTimeoutHandle = setTimeout(kc.onTokenExpired, expiresIn);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -697,15 +738,11 @@
|
|||||||
|
|
||||||
function parseCallback(url) {
|
function parseCallback(url) {
|
||||||
var oauth = new CallbackParser(url, kc.responseMode).parseUri();
|
var oauth = new CallbackParser(url, kc.responseMode).parseUri();
|
||||||
|
var oauthState = callbackStorage.get(oauth.state);
|
||||||
|
|
||||||
var oauthState = storage.getItem('oauthState');
|
if (oauthState && (oauth.code || oauth.error || oauth.access_token || oauth.id_token)) {
|
||||||
var sessionState = oauthState && JSON.parse(oauthState);
|
oauth.redirectUri = oauthState.redirectUri;
|
||||||
|
oauth.storedNonce = oauthState.nonce;
|
||||||
if (sessionState && (oauth.code || oauth.error || oauth.access_token || oauth.id_token) && oauth.state && oauth.state == sessionState.state) {
|
|
||||||
storage.removeItem('oauthState');
|
|
||||||
|
|
||||||
oauth.redirectUri = sessionState.redirectUri;
|
|
||||||
oauth.storedNonce = sessionState.nonce;
|
|
||||||
|
|
||||||
if (oauth.fragment) {
|
if (oauth.fragment) {
|
||||||
oauth.newUrl += '#' + oauth.fragment;
|
oauth.newUrl += '#' + oauth.fragment;
|
||||||
@@ -792,8 +829,22 @@
|
|||||||
if (event.origin !== loginIframe.iframeOrigin) {
|
if (event.origin !== loginIframe.iframeOrigin) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
var data = JSON.parse(event.data);
|
var data = JSON.parse(event.data);
|
||||||
|
} catch (err) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.callbackId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var promise = loginIframe.callbackMap[data.callbackId];
|
var promise = loginIframe.callbackMap[data.callbackId];
|
||||||
|
if (!promise) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
delete loginIframe.callbackMap[data.callbackId];
|
delete loginIframe.callbackMap[data.callbackId];
|
||||||
|
|
||||||
if ((!kc.sessionId || kc.sessionId == data.session) && data.loggedIn) {
|
if ((!kc.sessionId || kc.sessionId == data.session) && data.loggedIn) {
|
||||||
@@ -982,60 +1033,93 @@
|
|||||||
throw 'invalid adapter type: ' + type;
|
throw 'invalid adapter type: ' + type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var LocalStorage = function() {
|
||||||
|
if (!(this instanceof LocalStorage)) {
|
||||||
|
return new LocalStorage();
|
||||||
|
}
|
||||||
|
|
||||||
var PersistentStorage = function() {
|
localStorage.setItem('kc-test', 'test');
|
||||||
if (!(this instanceof PersistentStorage)) {
|
localStorage.removeItem('kc-test');
|
||||||
return new PersistentStorage();
|
|
||||||
}
|
var cs = this;
|
||||||
var ps = this;
|
|
||||||
var useCookieStorage = function () {
|
function clearExpired() {
|
||||||
if (typeof localStorage === "undefined") {
|
var time = new Date().getTime();
|
||||||
return true;
|
for (var i = 1; i <= localStorage.length; i++) {
|
||||||
}
|
var key = localStorage.key(i);
|
||||||
|
if (key && key.indexOf('kc-callback-') == 0) {
|
||||||
|
var value = localStorage.getItem(key);
|
||||||
|
if (value) {
|
||||||
try {
|
try {
|
||||||
var key = '@@keycloak-session-storage/test';
|
var expires = JSON.parse(value).expires;
|
||||||
localStorage.setItem(key, 'test');
|
if (!expires || expires < time) {
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key);
|
||||||
return false;
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Probably in Safari "private mode" where localStorage
|
|
||||||
// quota is 0, or quota exceeded. Switching to cookie
|
|
||||||
// storage.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ps.setItem = function(key, value) {
|
|
||||||
if (useCookieStorage()) {
|
|
||||||
setCookie(key, value, cookieExpiration(5));
|
|
||||||
} else {
|
|
||||||
localStorage.setItem(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ps.getItem = function(key) {
|
|
||||||
if (useCookieStorage()) {
|
|
||||||
return getCookie(key);
|
|
||||||
}
|
|
||||||
return localStorage.getItem(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
ps.removeItem = function(key) {
|
|
||||||
if (typeof localStorage !== "undefined") {
|
|
||||||
try {
|
|
||||||
// Always try to delete from localStorage.
|
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key);
|
||||||
} catch (err) { }
|
|
||||||
}
|
}
|
||||||
// Always remove the cookie.
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cs.get = function(state) {
|
||||||
|
if (!state) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var key = 'kc-callback-' + state;
|
||||||
|
var value = localStorage.getItem(key);
|
||||||
|
if (value) {
|
||||||
|
localStorage.removeItem(key);
|
||||||
|
value = JSON.parse(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
clearExpired();
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
cs.add = function(state) {
|
||||||
|
clearExpired();
|
||||||
|
|
||||||
|
var key = 'kc-callback-' + state.state;
|
||||||
|
state.expires = new Date().getTime() + (60 * 60 * 1000);
|
||||||
|
localStorage.setItem(key, JSON.stringify(state));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var CookieStorage = function() {
|
||||||
|
if (!(this instanceof CookieStorage)) {
|
||||||
|
return new CookieStorage();
|
||||||
|
}
|
||||||
|
|
||||||
|
var cs = this;
|
||||||
|
|
||||||
|
cs.get = function(state) {
|
||||||
|
if (!state) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = getCookie('kc-callback-' + state);
|
||||||
|
setCookie('kc-callback-' + state, '', cookieExpiration(-100));
|
||||||
|
if (value) {
|
||||||
|
return JSON.parse(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
cs.add = function(state) {
|
||||||
|
setCookie('kc-callback-' + state.state, JSON.stringify(state), cookieExpiration(60));
|
||||||
|
};
|
||||||
|
|
||||||
|
cs.removeItem = function(key) {
|
||||||
setCookie(key, '', cookieExpiration(-100));
|
setCookie(key, '', cookieExpiration(-100));
|
||||||
}
|
};
|
||||||
|
|
||||||
var cookieExpiration = function (minutes) {
|
var cookieExpiration = function (minutes) {
|
||||||
var exp = new Date();
|
var exp = new Date();
|
||||||
exp.setTime(exp.getTime() + (minutes*60*1000));
|
exp.setTime(exp.getTime() + (minutes*60*1000));
|
||||||
return exp;
|
return exp;
|
||||||
}
|
};
|
||||||
|
|
||||||
var getCookie = function (key) {
|
var getCookie = function (key) {
|
||||||
var name = key + '=';
|
var name = key + '=';
|
||||||
@@ -1050,13 +1134,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
};
|
||||||
|
|
||||||
var setCookie = function (key, value, expirationDate) {
|
var setCookie = function (key, value, expirationDate) {
|
||||||
var cookie = key + '=' + value + '; '
|
var cookie = key + '=' + value + '; '
|
||||||
+ 'expires=' + expirationDate.toUTCString() + '; ';
|
+ 'expires=' + expirationDate.toUTCString() + '; ';
|
||||||
document.cookie = cookie;
|
document.cookie = cookie;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function createCallbackStorage() {
|
||||||
|
try {
|
||||||
|
return new LocalStorage();
|
||||||
|
} catch (err) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CookieStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
var CallbackParser = function(uriToParse, responseMode) {
|
var CallbackParser = function(uriToParse, responseMode) {
|
||||||
@@ -1103,7 +1196,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var handleQueryParam = function(paramName, paramValue, oauth) {
|
var handleQueryParam = function(paramName, paramValue, oauth) {
|
||||||
var supportedOAuthParams = [ 'code', 'error', 'state' ];
|
var supportedOAuthParams = [ 'code', 'state', 'error', 'error_description' ];
|
||||||
|
|
||||||
for (var i = 0 ; i< supportedOAuthParams.length ; i++) {
|
for (var i = 0 ; i< supportedOAuthParams.length ; i++) {
|
||||||
if (paramName === supportedOAuthParams[i]) {
|
if (paramName === supportedOAuthParams[i]) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak OIDC Client Adapter Modules</name>
|
<name>Keycloak OIDC Client Adapter Modules</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+47
-7
@@ -47,6 +47,7 @@ import java.io.InputStream;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
@@ -56,10 +57,18 @@ public class KeycloakOIDCFilter implements Filter {
|
|||||||
protected AdapterDeploymentContext deploymentContext;
|
protected AdapterDeploymentContext deploymentContext;
|
||||||
protected SessionIdMapper idMapper = new InMemorySessionIdMapper();
|
protected SessionIdMapper idMapper = new InMemorySessionIdMapper();
|
||||||
protected NodesRegistrationManagement nodesRegistrationManagement;
|
protected NodesRegistrationManagement nodesRegistrationManagement;
|
||||||
|
protected Pattern skipPattern;
|
||||||
|
|
||||||
private final static Logger log = Logger.getLogger(""+KeycloakOIDCFilter.class);
|
private final static Logger log = Logger.getLogger(""+KeycloakOIDCFilter.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final FilterConfig filterConfig) throws ServletException {
|
public void init(final FilterConfig filterConfig) throws ServletException {
|
||||||
|
|
||||||
|
String skipPatternDefinition = filterConfig.getInitParameter("keycloak.config.skipPattern");
|
||||||
|
if (skipPatternDefinition != null) {
|
||||||
|
skipPattern = Pattern.compile(skipPatternDefinition, Pattern.DOTALL);
|
||||||
|
}
|
||||||
|
|
||||||
String configResolverClass = filterConfig.getInitParameter("keycloak.config.resolver");
|
String configResolverClass = filterConfig.getInitParameter("keycloak.config.resolver");
|
||||||
if (configResolverClass != null) {
|
if (configResolverClass != null) {
|
||||||
try {
|
try {
|
||||||
@@ -85,13 +94,7 @@ public class KeycloakOIDCFilter implements Filter {
|
|||||||
if (pathParam != null) path = pathParam;
|
if (pathParam != null) path = pathParam;
|
||||||
is = filterConfig.getServletContext().getResourceAsStream(path);
|
is = filterConfig.getServletContext().getResourceAsStream(path);
|
||||||
}
|
}
|
||||||
KeycloakDeployment kd;
|
KeycloakDeployment kd = createKeycloakDeploymentFrom(is);
|
||||||
if (is == null) {
|
|
||||||
log.fine("No adapter configuration. Keycloak is unconfigured and will deny all requests.");
|
|
||||||
kd = new KeycloakDeployment();
|
|
||||||
} else {
|
|
||||||
kd = KeycloakDeploymentBuilder.build(is);
|
|
||||||
}
|
|
||||||
deploymentContext = new AdapterDeploymentContext(kd);
|
deploymentContext = new AdapterDeploymentContext(kd);
|
||||||
log.fine("Keycloak is using a per-deployment configuration.");
|
log.fine("Keycloak is using a per-deployment configuration.");
|
||||||
}
|
}
|
||||||
@@ -99,13 +102,30 @@ public class KeycloakOIDCFilter implements Filter {
|
|||||||
nodesRegistrationManagement = new NodesRegistrationManagement();
|
nodesRegistrationManagement = new NodesRegistrationManagement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private KeycloakDeployment createKeycloakDeploymentFrom(InputStream is) {
|
||||||
|
|
||||||
|
if (is == null) {
|
||||||
|
log.fine("No adapter configuration. Keycloak is unconfigured and will deny all requests.");
|
||||||
|
return new KeycloakDeployment();
|
||||||
|
}
|
||||||
|
|
||||||
|
return KeycloakDeploymentBuilder.build(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||||
|
|
||||||
log.fine("Keycloak OIDC Filter");
|
log.fine("Keycloak OIDC Filter");
|
||||||
//System.err.println("Keycloak OIDC Filter: " + ((HttpServletRequest)req).getRequestURL().toString());
|
//System.err.println("Keycloak OIDC Filter: " + ((HttpServletRequest)req).getRequestURL().toString());
|
||||||
HttpServletRequest request = (HttpServletRequest) req;
|
HttpServletRequest request = (HttpServletRequest) req;
|
||||||
HttpServletResponse response = (HttpServletResponse) res;
|
HttpServletResponse response = (HttpServletResponse) res;
|
||||||
|
|
||||||
|
if (shouldSkip(request)) {
|
||||||
|
chain.doFilter(req, res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
OIDCServletHttpFacade facade = new OIDCServletHttpFacade(request, response);
|
OIDCServletHttpFacade facade = new OIDCServletHttpFacade(request, response);
|
||||||
KeycloakDeployment deployment = deploymentContext.resolveDeployment(facade);
|
KeycloakDeployment deployment = deploymentContext.resolveDeployment(facade);
|
||||||
if (deployment == null || !deployment.isConfigured()) {
|
if (deployment == null || !deployment.isConfigured()) {
|
||||||
@@ -171,6 +191,26 @@ public class KeycloakOIDCFilter implements Filter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decides whether this {@link Filter} should skip the given {@link HttpServletRequest} based on the configured {@link KeycloakOIDCFilter#skipPattern}.
|
||||||
|
* Patterns are matched against the {@link HttpServletRequest#getRequestURI() requestURI} of a request without the context-path.
|
||||||
|
* A request for {@code /myapp/index.html} would be tested with {@code /index.html} against the skip pattern.
|
||||||
|
* Skipped requests will not be processed further by {@link KeycloakOIDCFilter} and immediately delegated to the {@link FilterChain}.
|
||||||
|
*
|
||||||
|
* @param request the request to check
|
||||||
|
* @return {@code true} if the request should not be handled,
|
||||||
|
* {@code false} otherwise.
|
||||||
|
*/
|
||||||
|
private boolean shouldSkip(HttpServletRequest request) {
|
||||||
|
|
||||||
|
if (skipPattern == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String requestPath = request.getRequestURI().substring(request.getContextPath().length());
|
||||||
|
return skipPattern.matcher(requestPath).matches();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+5
-4
@@ -30,6 +30,7 @@ import org.keycloak.jose.jws.JWSInputException;
|
|||||||
import org.keycloak.representations.AccessTokenResponse;
|
import org.keycloak.representations.AccessTokenResponse;
|
||||||
import org.keycloak.representations.IDToken;
|
import org.keycloak.representations.IDToken;
|
||||||
import org.keycloak.common.util.KeycloakUriBuilder;
|
import org.keycloak.common.util.KeycloakUriBuilder;
|
||||||
|
import org.keycloak.util.TokenUtil;
|
||||||
|
|
||||||
import javax.security.cert.X509Certificate;
|
import javax.security.cert.X509Certificate;
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
@@ -91,15 +92,15 @@ public class ServletOAuthClient extends KeycloakDeploymentDelegateOAuthClient {
|
|||||||
String state = getStateCode();
|
String state = getStateCode();
|
||||||
KeycloakDeployment resolvedDeployment = resolveDeployment(getDeployment(), request);
|
KeycloakDeployment resolvedDeployment = resolveDeployment(getDeployment(), request);
|
||||||
String authUrl = resolvedDeployment.getAuthUrl().clone().build().toString();
|
String authUrl = resolvedDeployment.getAuthUrl().clone().build().toString();
|
||||||
|
String scopeParam = TokenUtil.attachOIDCScope(scope);
|
||||||
|
|
||||||
KeycloakUriBuilder uriBuilder = KeycloakUriBuilder.fromUri(authUrl)
|
KeycloakUriBuilder uriBuilder = KeycloakUriBuilder.fromUri(authUrl)
|
||||||
.queryParam(OAuth2Constants.RESPONSE_TYPE, OAuth2Constants.CODE)
|
.queryParam(OAuth2Constants.RESPONSE_TYPE, OAuth2Constants.CODE)
|
||||||
.queryParam(OAuth2Constants.CLIENT_ID, getClientId())
|
.queryParam(OAuth2Constants.CLIENT_ID, getClientId())
|
||||||
.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri)
|
.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri)
|
||||||
.queryParam(OAuth2Constants.STATE, state);
|
.queryParam(OAuth2Constants.STATE, state)
|
||||||
if (scope != null) {
|
.queryParam(OAuth2Constants.SCOPE, scopeParam);
|
||||||
uriBuilder.queryParam(OAuth2Constants.SCOPE, scope);
|
|
||||||
}
|
|
||||||
URI url = uriBuilder.build();
|
URI url = uriBuilder.build();
|
||||||
|
|
||||||
String stateCookiePath = this.stateCookiePath;
|
String stateCookiePath = this.stateCookiePath;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -67,6 +67,45 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-server</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-security</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-webapp</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.undertow</groupId>
|
||||||
|
<artifactId>undertow-servlet</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.undertow</groupId>
|
||||||
|
<artifactId>undertow-core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-undertow-adapter-spi</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|||||||
+154
-8
@@ -17,24 +17,38 @@
|
|||||||
|
|
||||||
package org.keycloak.adapters.springboot;
|
package org.keycloak.adapters.springboot;
|
||||||
|
|
||||||
|
import io.undertow.servlet.api.DeploymentInfo;
|
||||||
|
import io.undertow.servlet.api.WebResourceCollection;
|
||||||
import org.apache.catalina.Context;
|
import org.apache.catalina.Context;
|
||||||
import org.apache.tomcat.util.descriptor.web.LoginConfig;
|
import org.apache.tomcat.util.descriptor.web.LoginConfig;
|
||||||
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
||||||
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
|
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
|
||||||
|
import org.eclipse.jetty.security.ConstraintMapping;
|
||||||
|
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||||
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.util.security.Constraint;
|
||||||
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
import org.keycloak.adapters.jetty.KeycloakJettyAuthenticator;
|
||||||
import org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve;
|
import org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve;
|
||||||
|
import org.keycloak.adapters.undertow.KeycloakServletExtension;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
||||||
|
import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
|
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
||||||
|
import org.springframework.boot.context.embedded.undertow.UndertowDeploymentInfoCustomizer;
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,24 +75,158 @@ public class KeycloakSpringBootConfiguration {
|
|||||||
return new EmbeddedServletContainerCustomizer() {
|
return new EmbeddedServletContainerCustomizer() {
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
|
public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
|
||||||
|
|
||||||
if (configurableEmbeddedServletContainer instanceof TomcatEmbeddedServletContainerFactory) {
|
if (configurableEmbeddedServletContainer instanceof TomcatEmbeddedServletContainerFactory) {
|
||||||
|
|
||||||
TomcatEmbeddedServletContainerFactory container = (TomcatEmbeddedServletContainerFactory) configurableEmbeddedServletContainer;
|
TomcatEmbeddedServletContainerFactory container = (TomcatEmbeddedServletContainerFactory) configurableEmbeddedServletContainer;
|
||||||
|
|
||||||
container.addContextValves(new KeycloakAuthenticatorValve());
|
container.addContextValves(new KeycloakAuthenticatorValve());
|
||||||
|
container.addContextCustomizers(tomcatKeycloakContextCustomizer());
|
||||||
|
|
||||||
container.addContextCustomizers(getTomcatKeycloakContextCustomizer());
|
|
||||||
} else if (configurableEmbeddedServletContainer instanceof UndertowEmbeddedServletContainerFactory) {
|
} else if (configurableEmbeddedServletContainer instanceof UndertowEmbeddedServletContainerFactory) {
|
||||||
throw new IllegalArgumentException("Undertow Keycloak integration is not yet implemented");
|
|
||||||
|
UndertowEmbeddedServletContainerFactory container = (UndertowEmbeddedServletContainerFactory) configurableEmbeddedServletContainer;
|
||||||
|
container.addDeploymentInfoCustomizers(undertowKeycloakContextCustomizer());
|
||||||
|
|
||||||
} else if (configurableEmbeddedServletContainer instanceof JettyEmbeddedServletContainerFactory) {
|
} else if (configurableEmbeddedServletContainer instanceof JettyEmbeddedServletContainerFactory) {
|
||||||
throw new IllegalArgumentException("Jetty Keycloak integration is not yet implemented");
|
|
||||||
|
JettyEmbeddedServletContainerFactory container = (JettyEmbeddedServletContainerFactory) configurableEmbeddedServletContainer;
|
||||||
|
container.addServerCustomizers(jettyKeycloakServerCustomizer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatContextCustomizer getTomcatKeycloakContextCustomizer() {
|
@ConditionalOnClass(name = {"org.eclipse.jetty.webapp.WebAppContext"})
|
||||||
return new TomcatContextCustomizer() {
|
public JettyServerCustomizer jettyKeycloakServerCustomizer() {
|
||||||
|
return new KeycloakJettyServerCustomizer(keycloakProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnClass(name = {"org.apache.catalina.startup.Tomcat"})
|
||||||
|
public TomcatContextCustomizer tomcatKeycloakContextCustomizer() {
|
||||||
|
return new KeycloakTomcatContextCustomizer(keycloakProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnClass(name = {"io.undertow.Undertow"})
|
||||||
|
public UndertowDeploymentInfoCustomizer undertowKeycloakContextCustomizer() {
|
||||||
|
return new KeycloakUndertowDeploymentInfoCustomizer(keycloakProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class KeycloakUndertowDeploymentInfoCustomizer implements UndertowDeploymentInfoCustomizer {
|
||||||
|
|
||||||
|
private final KeycloakSpringBootProperties keycloakProperties;
|
||||||
|
|
||||||
|
public KeycloakUndertowDeploymentInfoCustomizer(KeycloakSpringBootProperties keycloakProperties) {
|
||||||
|
this.keycloakProperties = keycloakProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customize(DeploymentInfo deploymentInfo) {
|
||||||
|
|
||||||
|
io.undertow.servlet.api.LoginConfig loginConfig = new io.undertow.servlet.api.LoginConfig(keycloakProperties.getRealm());
|
||||||
|
loginConfig.addFirstAuthMethod("KEYCLOAK");
|
||||||
|
|
||||||
|
deploymentInfo.setLoginConfig(loginConfig);
|
||||||
|
|
||||||
|
deploymentInfo.addInitParameter("keycloak.config.resolver", KeycloakSpringBootConfigResolver.class.getName());
|
||||||
|
deploymentInfo.addSecurityConstraints(getSecurityConstraints());
|
||||||
|
|
||||||
|
deploymentInfo.addServletExtension(new KeycloakServletExtension());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<io.undertow.servlet.api.SecurityConstraint> getSecurityConstraints() {
|
||||||
|
|
||||||
|
List<io.undertow.servlet.api.SecurityConstraint> undertowSecurityConstraints = new ArrayList<io.undertow.servlet.api.SecurityConstraint>();
|
||||||
|
for (KeycloakSpringBootProperties.SecurityConstraint constraintDefinition : keycloakProperties.getSecurityConstraints()) {
|
||||||
|
|
||||||
|
for (KeycloakSpringBootProperties.SecurityCollection collectionDefinition : constraintDefinition.getSecurityCollections()) {
|
||||||
|
|
||||||
|
io.undertow.servlet.api.SecurityConstraint undertowSecurityConstraint = new io.undertow.servlet.api.SecurityConstraint();
|
||||||
|
undertowSecurityConstraint.addRolesAllowed(collectionDefinition.getAuthRoles());
|
||||||
|
|
||||||
|
WebResourceCollection webResourceCollection = new WebResourceCollection();
|
||||||
|
webResourceCollection.addHttpMethods(collectionDefinition.getMethods());
|
||||||
|
webResourceCollection.addHttpMethodOmissions(collectionDefinition.getOmittedMethods());
|
||||||
|
webResourceCollection.addUrlPatterns(collectionDefinition.getPatterns());
|
||||||
|
|
||||||
|
undertowSecurityConstraint.addWebResourceCollections(webResourceCollection);
|
||||||
|
|
||||||
|
undertowSecurityConstraints.add(undertowSecurityConstraint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undertowSecurityConstraints;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class KeycloakJettyServerCustomizer implements JettyServerCustomizer {
|
||||||
|
|
||||||
|
private final KeycloakSpringBootProperties keycloakProperties;
|
||||||
|
|
||||||
|
public KeycloakJettyServerCustomizer(KeycloakSpringBootProperties keycloakProperties) {
|
||||||
|
this.keycloakProperties = keycloakProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customize(Server server) {
|
||||||
|
|
||||||
|
KeycloakJettyAuthenticator keycloakJettyAuthenticator = new KeycloakJettyAuthenticator();
|
||||||
|
keycloakJettyAuthenticator.setConfigResolver(new KeycloakSpringBootConfigResolver());
|
||||||
|
|
||||||
|
List<ConstraintMapping> jettyConstraintMappings = new ArrayList<ConstraintMapping>();
|
||||||
|
for (KeycloakSpringBootProperties.SecurityConstraint constraintDefinition : keycloakProperties.getSecurityConstraints()) {
|
||||||
|
|
||||||
|
for (KeycloakSpringBootProperties.SecurityCollection securityCollectionDefinition : constraintDefinition
|
||||||
|
.getSecurityCollections()) {
|
||||||
|
|
||||||
|
Constraint jettyConstraint = new Constraint();
|
||||||
|
jettyConstraint.setName(securityCollectionDefinition.getName());
|
||||||
|
jettyConstraint.setAuthenticate(true);
|
||||||
|
|
||||||
|
if (securityCollectionDefinition.getName() != null) {
|
||||||
|
jettyConstraint.setName(securityCollectionDefinition.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
jettyConstraint.setRoles(securityCollectionDefinition.getAuthRoles().toArray(new String[0]));
|
||||||
|
|
||||||
|
ConstraintMapping jettyConstraintMapping = new ConstraintMapping();
|
||||||
|
if (securityCollectionDefinition.getPatterns().size() > 0) {
|
||||||
|
//First pattern wins
|
||||||
|
jettyConstraintMapping.setPathSpec(securityCollectionDefinition.getPatterns().get(0));
|
||||||
|
jettyConstraintMapping.setConstraint(jettyConstraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (securityCollectionDefinition.getMethods().size() > 0) {
|
||||||
|
//First method wins
|
||||||
|
jettyConstraintMapping.setMethod(securityCollectionDefinition.getMethods().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
jettyConstraintMapping.setMethodOmissions(
|
||||||
|
securityCollectionDefinition.getOmittedMethods().toArray(new String[0]));
|
||||||
|
|
||||||
|
jettyConstraintMappings.add(jettyConstraintMapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WebAppContext webAppContext = server.getBean(WebAppContext.class);
|
||||||
|
|
||||||
|
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
|
||||||
|
securityHandler.setConstraintMappings(jettyConstraintMappings);
|
||||||
|
securityHandler.setAuthenticator(keycloakJettyAuthenticator);
|
||||||
|
|
||||||
|
webAppContext.setHandler(securityHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class KeycloakTomcatContextCustomizer implements TomcatContextCustomizer {
|
||||||
|
|
||||||
|
private final KeycloakSpringBootProperties keycloakProperties;
|
||||||
|
|
||||||
|
public KeycloakTomcatContextCustomizer(KeycloakSpringBootProperties keycloakProperties) {
|
||||||
|
this.keycloakProperties = keycloakProperties;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(Context context) {
|
public void customize(Context context) {
|
||||||
LoginConfig loginConfig = new LoginConfig();
|
LoginConfig loginConfig = new LoginConfig();
|
||||||
@@ -134,7 +282,5 @@ public class KeycloakSpringBootConfiguration {
|
|||||||
|
|
||||||
context.addParameter("keycloak.config.resolver", KeycloakSpringBootConfigResolver.class.getName());
|
context.addParameter("keycloak.config.resolver", KeycloakSpringBootConfigResolver.class.getName());
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -71,6 +71,13 @@
|
|||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>${slf4j.version}</version>
|
<version>${slf4j.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.logging</groupId>
|
||||||
|
<artifactId>jboss-logging</artifactId>
|
||||||
|
<version>${jboss.logging.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
@@ -121,12 +128,6 @@
|
|||||||
<version>${slf4j.version}</version>
|
<version>${slf4j.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jboss.logging</groupId>
|
|
||||||
<artifactId>jboss-logging</artifactId>
|
|
||||||
<version>${jboss.logging.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
-1
@@ -69,6 +69,5 @@ public class HttpSessionManager implements HttpSessionListener, UserSessionManag
|
|||||||
session.invalidate();
|
session.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sessions.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak Tomcat Integration</name>
|
<name>Keycloak Tomcat Integration</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-tomcat-integration-pom</artifactId>
|
<artifactId>keycloak-tomcat-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -77,6 +77,13 @@
|
|||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Authorization -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-authz-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat</groupId>
|
<groupId>org.apache.tomcat</groupId>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-tomcat-integration-pom</artifactId>
|
<artifactId>keycloak-tomcat-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-tomcat-integration-pom</artifactId>
|
<artifactId>keycloak-tomcat-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-tomcat-integration-pom</artifactId>
|
<artifactId>keycloak-tomcat-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak WildFly Integration</name>
|
<name>Keycloak WildFly Integration</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
+8
-10
@@ -46,8 +46,7 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
|
|
||||||
// not sure if we need this yet, keeping here just in case
|
// not sure if we need this yet, keeping here just in case
|
||||||
protected void addSecurityDomain(DeploymentUnit deploymentUnit, KeycloakAdapterConfigService service) {
|
protected void addSecurityDomain(DeploymentUnit deploymentUnit, KeycloakAdapterConfigService service) {
|
||||||
String deploymentName = deploymentUnit.getName();
|
if (!service.isSecureDeployment(deploymentUnit)) {
|
||||||
if (!service.isSecureDeployment(deploymentName)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
@@ -67,10 +66,9 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
||||||
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
|
|
||||||
String deploymentName = deploymentUnit.getName();
|
|
||||||
KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
|
KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
|
||||||
if (service.isSecureDeployment(deploymentName)) {
|
if (service.isSecureDeployment(deploymentUnit)) {
|
||||||
addKeycloakAuthData(phaseContext, deploymentName, service);
|
addKeycloakAuthData(phaseContext, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FYI, Undertow Extension will find deployments that have auth-method set to KEYCLOAK
|
// FYI, Undertow Extension will find deployments that have auth-method set to KEYCLOAK
|
||||||
@@ -79,14 +77,14 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
// addSecurityDomain(deploymentUnit, service);
|
// addSecurityDomain(deploymentUnit, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addKeycloakAuthData(DeploymentPhaseContext phaseContext, String deploymentName, KeycloakAdapterConfigService service) throws DeploymentUnitProcessingException {
|
private void addKeycloakAuthData(DeploymentPhaseContext phaseContext, KeycloakAdapterConfigService service) throws DeploymentUnitProcessingException {
|
||||||
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
if (warMetaData == null) {
|
if (warMetaData == null) {
|
||||||
throw new DeploymentUnitProcessingException("WarMetaData not found for " + deploymentName + ". Make sure you have specified a WAR as your secure-deployment in the Keycloak subsystem.");
|
throw new DeploymentUnitProcessingException("WarMetaData not found for " + deploymentUnit.getName() + ". Make sure you have specified a WAR as your secure-deployment in the Keycloak subsystem.");
|
||||||
}
|
}
|
||||||
|
|
||||||
addJSONData(service.getJSON(deploymentName), warMetaData);
|
addJSONData(service.getJSON(deploymentUnit), warMetaData);
|
||||||
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
|
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
|
||||||
if (webMetaData == null) {
|
if (webMetaData == null) {
|
||||||
webMetaData = new JBossWebMetaData();
|
webMetaData = new JBossWebMetaData();
|
||||||
@@ -99,8 +97,8 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
webMetaData.setLoginConfig(loginConfig);
|
webMetaData.setLoginConfig(loginConfig);
|
||||||
}
|
}
|
||||||
loginConfig.setAuthMethod("KEYCLOAK");
|
loginConfig.setAuthMethod("KEYCLOAK");
|
||||||
loginConfig.setRealmName(service.getRealmName(deploymentName));
|
loginConfig.setRealmName(service.getRealmName(deploymentUnit));
|
||||||
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentName);
|
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentUnit.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addJSONData(String json, WarMetaData warMetaData) {
|
private void addJSONData(String json, WarMetaData warMetaData) {
|
||||||
|
|||||||
+28
-3
@@ -24,6 +24,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
|
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
|
||||||
|
import org.jboss.as.server.deployment.DeploymentUnit;
|
||||||
|
import org.jboss.as.web.common.WarMetaData;
|
||||||
|
import org.jboss.metadata.web.jboss.JBossWebMetaData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service keeps track of the entire Keycloak management model so as to provide
|
* This service keeps track of the entire Keycloak management model so as to provide
|
||||||
@@ -153,13 +156,15 @@ public final class KeycloakAdapterConfigService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRealmName(String deploymentName) {
|
public String getRealmName(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
||||||
return deployment.get(RealmDefinition.TAG_NAME).asString();
|
return deployment.get(RealmDefinition.TAG_NAME).asString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJSON(String deploymentName) {
|
public String getJSON(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
||||||
String realmName = deployment.get(RealmDefinition.TAG_NAME).asString();
|
String realmName = deployment.get(RealmDefinition.TAG_NAME).asString();
|
||||||
ModelNode realm = this.realms.get(realmName);
|
ModelNode realm = this.realms.get(realmName);
|
||||||
@@ -183,9 +188,29 @@ public final class KeycloakAdapterConfigService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSecureDeployment(String deploymentName) {
|
public boolean isSecureDeployment(DeploymentUnit deploymentUnit) {
|
||||||
//log.info("********* CHECK KEYCLOAK DEPLOYMENT: deployments.size()" + deployments.size());
|
//log.info("********* CHECK KEYCLOAK DEPLOYMENT: deployments.size()" + deployments.size());
|
||||||
|
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
return this.secureDeployments.containsKey(deploymentName);
|
return this.secureDeployments.containsKey(deploymentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KEYCLOAK-3273: prefer module name if available
|
||||||
|
private String preferredDeploymentName(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = deploymentUnit.getName();
|
||||||
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
|
if (warMetaData == null) {
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
|
||||||
|
if (webMetaData == null) {
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String moduleName = webMetaData.getModuleName();
|
||||||
|
if (moduleName != null) return moduleName + ".war";
|
||||||
|
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -46,8 +46,7 @@ public abstract class KeycloakDependencyProcessor implements DeploymentUnitProce
|
|||||||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
||||||
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
|
|
||||||
String deploymentName = deploymentUnit.getName();
|
if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentUnit)) {
|
||||||
if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentName)) {
|
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
if (warMetaData == null) {
|
if (warMetaData == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
-2
@@ -78,8 +78,6 @@ public class SubsystemParsingTestCase extends AbstractSubsystemBaseTest {
|
|||||||
addCredential(addr, service, "secret", "secret1");
|
addCredential(addr, service, "secret", "secret1");
|
||||||
addCredential(addr, service, "jwt.client-keystore-file", "/tmp/foo.jks");
|
addCredential(addr, service, "jwt.client-keystore-file", "/tmp/foo.jks");
|
||||||
addCredential(addr, service, "jwt.token-timeout", "10");
|
addCredential(addr, service, "jwt.token-timeout", "10");
|
||||||
|
|
||||||
System.out.println("Deployment: " + service.getJSON("foo"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCredential(PathAddress parent, KeycloakAdapterConfigService service, String key, String value) {
|
private void addCredential(PathAddress parent, KeycloakAdapterConfigService service, String key, String value) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
+8
-10
@@ -46,8 +46,7 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
|
|
||||||
// not sure if we need this yet, keeping here just in case
|
// not sure if we need this yet, keeping here just in case
|
||||||
protected void addSecurityDomain(DeploymentUnit deploymentUnit, KeycloakAdapterConfigService service) {
|
protected void addSecurityDomain(DeploymentUnit deploymentUnit, KeycloakAdapterConfigService service) {
|
||||||
String deploymentName = deploymentUnit.getName();
|
if (!service.isSecureDeployment(deploymentUnit)) {
|
||||||
if (!service.isSecureDeployment(deploymentName)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
@@ -67,10 +66,9 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
||||||
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
|
|
||||||
String deploymentName = deploymentUnit.getName();
|
|
||||||
KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
|
KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
|
||||||
if (service.isSecureDeployment(deploymentName)) {
|
if (service.isSecureDeployment(deploymentUnit)) {
|
||||||
addKeycloakAuthData(phaseContext, deploymentName, service);
|
addKeycloakAuthData(phaseContext, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FYI, Undertow Extension will find deployments that have auth-method set to KEYCLOAK
|
// FYI, Undertow Extension will find deployments that have auth-method set to KEYCLOAK
|
||||||
@@ -79,14 +77,14 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
// addSecurityDomain(deploymentUnit, service);
|
// addSecurityDomain(deploymentUnit, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addKeycloakAuthData(DeploymentPhaseContext phaseContext, String deploymentName, KeycloakAdapterConfigService service) throws DeploymentUnitProcessingException {
|
private void addKeycloakAuthData(DeploymentPhaseContext phaseContext, KeycloakAdapterConfigService service) throws DeploymentUnitProcessingException {
|
||||||
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
if (warMetaData == null) {
|
if (warMetaData == null) {
|
||||||
throw new DeploymentUnitProcessingException("WarMetaData not found for " + deploymentName + ". Make sure you have specified a WAR as your secure-deployment in the Keycloak subsystem.");
|
throw new DeploymentUnitProcessingException("WarMetaData not found for " + deploymentUnit.getName() + ". Make sure you have specified a WAR as your secure-deployment in the Keycloak subsystem.");
|
||||||
}
|
}
|
||||||
|
|
||||||
addJSONData(service.getJSON(deploymentName), warMetaData);
|
addJSONData(service.getJSON(deploymentUnit), warMetaData);
|
||||||
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
|
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
|
||||||
if (webMetaData == null) {
|
if (webMetaData == null) {
|
||||||
webMetaData = new JBossWebMetaData();
|
webMetaData = new JBossWebMetaData();
|
||||||
@@ -99,8 +97,8 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
webMetaData.setLoginConfig(loginConfig);
|
webMetaData.setLoginConfig(loginConfig);
|
||||||
}
|
}
|
||||||
loginConfig.setAuthMethod("KEYCLOAK");
|
loginConfig.setAuthMethod("KEYCLOAK");
|
||||||
loginConfig.setRealmName(service.getRealmName(deploymentName));
|
loginConfig.setRealmName(service.getRealmName(deploymentUnit));
|
||||||
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentName);
|
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentUnit.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addJSONData(String json, WarMetaData warMetaData) {
|
private void addJSONData(String json, WarMetaData warMetaData) {
|
||||||
|
|||||||
+28
-3
@@ -24,6 +24,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
|
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
|
||||||
|
import org.jboss.as.server.deployment.DeploymentUnit;
|
||||||
|
import org.jboss.as.web.common.WarMetaData;
|
||||||
|
import org.jboss.metadata.web.jboss.JBossWebMetaData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service keeps track of the entire Keycloak management model so as to provide
|
* This service keeps track of the entire Keycloak management model so as to provide
|
||||||
@@ -153,13 +156,15 @@ public final class KeycloakAdapterConfigService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRealmName(String deploymentName) {
|
public String getRealmName(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
||||||
return deployment.get(RealmDefinition.TAG_NAME).asString();
|
return deployment.get(RealmDefinition.TAG_NAME).asString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJSON(String deploymentName) {
|
public String getJSON(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
ModelNode deployment = this.secureDeployments.get(deploymentName);
|
||||||
String realmName = deployment.get(RealmDefinition.TAG_NAME).asString();
|
String realmName = deployment.get(RealmDefinition.TAG_NAME).asString();
|
||||||
ModelNode realm = this.realms.get(realmName);
|
ModelNode realm = this.realms.get(realmName);
|
||||||
@@ -183,9 +188,29 @@ public final class KeycloakAdapterConfigService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSecureDeployment(String deploymentName) {
|
public boolean isSecureDeployment(DeploymentUnit deploymentUnit) {
|
||||||
//log.info("********* CHECK KEYCLOAK DEPLOYMENT: deployments.size()" + deployments.size());
|
//log.info("********* CHECK KEYCLOAK DEPLOYMENT: deployments.size()" + deployments.size());
|
||||||
|
|
||||||
|
String deploymentName = preferredDeploymentName(deploymentUnit);
|
||||||
return this.secureDeployments.containsKey(deploymentName);
|
return this.secureDeployments.containsKey(deploymentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KEYCLOAK-3273: prefer module name if available
|
||||||
|
private String preferredDeploymentName(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = deploymentUnit.getName();
|
||||||
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
|
if (warMetaData == null) {
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
|
||||||
|
if (webMetaData == null) {
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String moduleName = webMetaData.getModuleName();
|
||||||
|
if (moduleName != null) return moduleName + ".war";
|
||||||
|
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-3
@@ -45,9 +45,7 @@ public abstract class KeycloakDependencyProcessor implements DeploymentUnitProce
|
|||||||
@Override
|
@Override
|
||||||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
||||||
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
|
if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentUnit)) {
|
||||||
String deploymentName = deploymentUnit.getName();
|
|
||||||
if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentName)) {
|
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
if (warMetaData == null) {
|
if (warMetaData == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
-2
@@ -78,8 +78,6 @@ public class SubsystemParsingTestCase extends AbstractSubsystemBaseTest {
|
|||||||
addCredential(addr, service, "secret", "secret1");
|
addCredential(addr, service, "secret", "secret1");
|
||||||
addCredential(addr, service, "jwt.client-keystore-file", "/tmp/foo.jks");
|
addCredential(addr, service, "jwt.client-keystore-file", "/tmp/foo.jks");
|
||||||
addCredential(addr, service, "jwt.token-timeout", "10");
|
addCredential(addr, service, "jwt.token-timeout", "10");
|
||||||
|
|
||||||
System.out.println("Deployment: " + service.getJSON("foo"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCredential(PathAddress parent, KeycloakAdapterConfigService service, String key, String value) {
|
private void addCredential(PathAddress parent, KeycloakAdapterConfigService service, String key, String value) {
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak Integration</name>
|
<name>Keycloak Integration</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-saml-eap-integration-pom</artifactId>
|
<artifactId>keycloak-saml-eap-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak SAML EAP Integration</name>
|
<name>Keycloak SAML EAP Integration</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<artifactId>keycloak-saml-eap-integration-pom</artifactId>
|
<artifactId>keycloak-saml-eap-integration-pom</artifactId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
+26
-3
@@ -16,8 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.keycloak.subsystem.saml.as7;
|
package org.keycloak.subsystem.saml.as7;
|
||||||
|
|
||||||
|
import org.jboss.as.server.deployment.DeploymentUnit;
|
||||||
|
import org.jboss.as.web.deployment.WarMetaData;
|
||||||
import org.jboss.dmr.ModelNode;
|
import org.jboss.dmr.ModelNode;
|
||||||
import org.jboss.dmr.Property;
|
import org.jboss.dmr.Property;
|
||||||
|
import org.jboss.metadata.web.jboss.JBossWebMetaData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
|
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
|
||||||
@@ -46,7 +49,8 @@ public class Configuration {
|
|||||||
return keymodel.get(key);
|
return keymodel.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelNode getSecureDeployment(String name) {
|
public ModelNode getSecureDeployment(DeploymentUnit deploymentUnit) {
|
||||||
|
String name = preferredDeploymentName(deploymentUnit);
|
||||||
ModelNode secureDeployment = config.get("subsystem").get("keycloak-saml").get(Constants.Model.SECURE_DEPLOYMENT);
|
ModelNode secureDeployment = config.get("subsystem").get("keycloak-saml").get(Constants.Model.SECURE_DEPLOYMENT);
|
||||||
if (secureDeployment.hasDefined(name)) {
|
if (secureDeployment.hasDefined(name)) {
|
||||||
return secureDeployment.get(name);
|
return secureDeployment.get(name);
|
||||||
@@ -54,7 +58,26 @@ public class Configuration {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSecureDeployment(String name) {
|
public boolean isSecureDeployment(DeploymentUnit deploymentUnit) {
|
||||||
return getSecureDeployment(name) != null;
|
return getSecureDeployment(deploymentUnit) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// KEYCLOAK-3273: prefer module name if available
|
||||||
|
private String preferredDeploymentName(DeploymentUnit deploymentUnit) {
|
||||||
|
String deploymentName = deploymentUnit.getName();
|
||||||
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
|
if (warMetaData == null) {
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
|
||||||
|
if (webMetaData == null) {
|
||||||
|
return deploymentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String moduleName = webMetaData.getModuleName();
|
||||||
|
if (moduleName != null) return moduleName + ".war";
|
||||||
|
|
||||||
|
return deploymentName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-8
@@ -51,7 +51,6 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
@Override
|
@Override
|
||||||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
||||||
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
String deploymentName = deploymentUnit.getName();
|
|
||||||
|
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
if (warMetaData == null) {
|
if (warMetaData == null) {
|
||||||
@@ -69,30 +68,30 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
boolean webRequiresKC = loginConfig != null && "KEYCLOAK-SAML".equalsIgnoreCase(loginConfig.getAuthMethod());
|
boolean webRequiresKC = loginConfig != null && "KEYCLOAK-SAML".equalsIgnoreCase(loginConfig.getAuthMethod());
|
||||||
boolean hasSubsystemConfig = Configuration.INSTANCE.isSecureDeployment(deploymentName);
|
boolean hasSubsystemConfig = Configuration.INSTANCE.isSecureDeployment(deploymentUnit);
|
||||||
if (hasSubsystemConfig || webRequiresKC) {
|
if (hasSubsystemConfig || webRequiresKC) {
|
||||||
log.debug("Setting up KEYCLOAK-SAML auth method for WAR: " + deploymentName);
|
log.debug("Setting up KEYCLOAK-SAML auth method for WAR: " + deploymentUnit.getName());
|
||||||
|
|
||||||
// if secure-deployment configuration exists for web app, we force KEYCLOAK-SAML auth method on it
|
// if secure-deployment configuration exists for web app, we force KEYCLOAK-SAML auth method on it
|
||||||
if (hasSubsystemConfig) {
|
if (hasSubsystemConfig) {
|
||||||
addXMLData(getXML(deploymentName), warMetaData);
|
addXMLData(getXML(deploymentUnit), warMetaData);
|
||||||
if (loginConfig != null) {
|
if (loginConfig != null) {
|
||||||
loginConfig.setAuthMethod("KEYCLOAK-SAML");
|
loginConfig.setAuthMethod("KEYCLOAK-SAML");
|
||||||
//loginConfig.setRealmName(service.getRealmName(deploymentName));
|
//loginConfig.setRealmName(service.getRealmName(deploymentName));
|
||||||
} else {
|
} else {
|
||||||
log.warn("Failed to set up KEYCLOAK-SAML auth method for WAR: " + deploymentName + " (loginConfig == null)");
|
log.warn("Failed to set up KEYCLOAK-SAML auth method for WAR: " + deploymentUnit.getName() + " (loginConfig == null)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addValve(webMetaData);
|
addValve(webMetaData);
|
||||||
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentName);
|
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentUnit.getName());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DeploymentUnitProcessingException("Failed to configure KeycloakSamlExtension from subsystem model", e);
|
throw new DeploymentUnitProcessingException("Failed to configure KeycloakSamlExtension from subsystem model", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getXML(String deploymentName) throws XMLStreamException {
|
private String getXML(DeploymentUnit deploymentUnit) throws XMLStreamException {
|
||||||
ModelNode node = Configuration.INSTANCE.getSecureDeployment(deploymentName);
|
ModelNode node = Configuration.INSTANCE.getSecureDeployment(deploymentUnit);
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
KeycloakSubsystemParser writer = new KeycloakSubsystemParser();
|
KeycloakSubsystemParser writer = new KeycloakSubsystemParser();
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
|||||||
+1
-2
@@ -46,8 +46,7 @@ public abstract class KeycloakDependencyProcessor implements DeploymentUnitProce
|
|||||||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
|
||||||
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
|
||||||
|
|
||||||
String deploymentName = deploymentUnit.getName();
|
if (Configuration.INSTANCE.getSecureDeployment(deploymentUnit) == null) {
|
||||||
if (Configuration.INSTANCE.getSecureDeployment(deploymentName) == null) {
|
|
||||||
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
|
||||||
if (warMetaData == null) {
|
if (warMetaData == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+2
-2
@@ -370,13 +370,13 @@ public abstract class AbstractSamlAuthenticator extends LoginAuthenticator {
|
|||||||
Authentication authentication = request.getAuthentication();
|
Authentication authentication = request.getAuthentication();
|
||||||
if (!(authentication instanceof KeycloakAuthentication)) {
|
if (!(authentication instanceof KeycloakAuthentication)) {
|
||||||
UserIdentity userIdentity = createIdentity(samlSession);
|
UserIdentity userIdentity = createIdentity(samlSession);
|
||||||
authentication = createAuthentication(userIdentity);
|
authentication = createAuthentication(userIdentity, request);
|
||||||
request.setAuthentication(authentication);
|
request.setAuthentication(authentication);
|
||||||
}
|
}
|
||||||
return authentication;
|
return authentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Authentication createAuthentication(UserIdentity userIdentity);
|
public abstract Authentication createAuthentication(UserIdentity userIdentity, Request request);
|
||||||
|
|
||||||
public static abstract class KeycloakAuthentication extends UserAuthentication {
|
public static abstract class KeycloakAuthentication extends UserAuthentication {
|
||||||
public KeycloakAuthentication(String method, UserIdentity userIdentity) {
|
public KeycloakAuthentication(String method, UserIdentity userIdentity) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+2
-1
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.keycloak.adapters.saml.jetty;
|
package org.keycloak.adapters.saml.jetty;
|
||||||
|
|
||||||
|
import org.bouncycastle.cert.ocsp.Req;
|
||||||
import org.eclipse.jetty.server.AbstractHttpConnection;
|
import org.eclipse.jetty.server.AbstractHttpConnection;
|
||||||
import org.eclipse.jetty.server.Authentication;
|
import org.eclipse.jetty.server.Authentication;
|
||||||
import org.eclipse.jetty.server.Request;
|
import org.eclipse.jetty.server.Request;
|
||||||
@@ -48,7 +49,7 @@ public class KeycloakSamlAuthenticator extends AbstractSamlAuthenticator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Authentication createAuthentication(UserIdentity userIdentity) {
|
public Authentication createAuthentication(UserIdentity userIdentity, Request request) {
|
||||||
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
||||||
@Override
|
@Override
|
||||||
public void logout() {
|
public void logout() {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+2
-1
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.keycloak.adapters.saml.jetty;
|
package org.keycloak.adapters.saml.jetty;
|
||||||
|
|
||||||
|
import org.bouncycastle.cert.ocsp.Req;
|
||||||
import org.eclipse.jetty.server.Authentication;
|
import org.eclipse.jetty.server.Authentication;
|
||||||
import org.eclipse.jetty.server.HttpChannel;
|
import org.eclipse.jetty.server.HttpChannel;
|
||||||
import org.eclipse.jetty.server.Request;
|
import org.eclipse.jetty.server.Request;
|
||||||
@@ -50,7 +51,7 @@ public class KeycloakSamlAuthenticator extends AbstractSamlAuthenticator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Authentication createAuthentication(UserIdentity userIdentity) {
|
public Authentication createAuthentication(UserIdentity userIdentity, Request request) {
|
||||||
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
||||||
@Override
|
@Override
|
||||||
public void logout() {
|
public void logout() {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ public class KeycloakSamlAuthenticator extends AbstractSamlAuthenticator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Authentication createAuthentication(UserIdentity userIdentity) {
|
public Authentication createAuthentication(UserIdentity userIdentity, Request request) {
|
||||||
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
||||||
@Override
|
@Override
|
||||||
public void logout() {
|
public void logout() {
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
~ and other contributors as indicated by the @author tags.
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>keycloak-parent</artifactId>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<version>2.2.1.Final</version>
|
||||||
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>keycloak-saml-jetty93-adapter</artifactId>
|
||||||
|
<name>Keycloak Jetty 9.3.x SAML Integration</name>
|
||||||
|
<properties>
|
||||||
|
<jetty9.version>9.3.9.v20160517</jetty9.version>
|
||||||
|
<keycloak.osgi.export>
|
||||||
|
org.keycloak.adapters.jetty.*
|
||||||
|
</keycloak.osgi.export>
|
||||||
|
<keycloak.osgi.import>
|
||||||
|
org.eclipse.jetty.*;resolution:=optional,
|
||||||
|
javax.servlet.*;version="[3.0,4)";resolution:=optional,
|
||||||
|
org.keycloak.*;version="${project.version}",
|
||||||
|
*;resolution:=optional
|
||||||
|
</keycloak.osgi.import>
|
||||||
|
</properties>
|
||||||
|
<description />
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.logging</groupId>
|
||||||
|
<artifactId>jboss-logging</artifactId>
|
||||||
|
<version>${jboss.logging.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-saml-adapter-api-public</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-saml-adapter-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-adapter-spi</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-saml-jetty-adapter-core</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-server</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-util</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-security</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-server</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-util</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-security</artifactId>
|
||||||
|
<version>${jetty9.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Adding OSGI metadata to the JAR without changing the packaging type. -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>bundle-manifest</id>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>manifest</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-ClassPath>.</Bundle-ClassPath>
|
||||||
|
<Bundle-Name>${project.name}</Bundle-Name>
|
||||||
|
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Import-Package>${keycloak.osgi.import}</Import-Package>
|
||||||
|
<Export-Package>${keycloak.osgi.export}</Export-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.adapters.saml.jetty;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.Request;
|
||||||
|
import org.keycloak.adapters.jetty.spi.JettyUserSessionManagement;
|
||||||
|
import org.keycloak.adapters.saml.SamlDeployment;
|
||||||
|
import org.keycloak.adapters.spi.AdapterSessionStore;
|
||||||
|
import org.keycloak.adapters.spi.HttpFacade;
|
||||||
|
import org.keycloak.adapters.spi.SessionIdMapper;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class Jetty9SamlSessionStore extends JettySamlSessionStore {
|
||||||
|
public Jetty9SamlSessionStore(Request request, AdapterSessionStore sessionStore, HttpFacade facade, SessionIdMapper idMapper, JettyUserSessionManagement sessionManagement, SamlDeployment deployment) {
|
||||||
|
super(request, sessionStore, facade, idMapper, sessionManagement, deployment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String changeSessionId(HttpSession session) {
|
||||||
|
Request request = this.request;
|
||||||
|
if (!deployment.turnOffChangeSessionIdOnLogin()) return request.changeSessionId();
|
||||||
|
else return session.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.adapters.saml.jetty;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
|
import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
||||||
|
import org.eclipse.jetty.server.Request;
|
||||||
|
import org.eclipse.jetty.util.MultiMap;
|
||||||
|
import org.keycloak.adapters.spi.AdapterSessionStore;
|
||||||
|
import org.keycloak.adapters.jetty.spi.JettyHttpFacade;
|
||||||
|
import org.keycloak.common.util.MultivaluedHashMap;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class JettyAdapterSessionStore implements AdapterSessionStore {
|
||||||
|
public static final String CACHED_FORM_PARAMETERS = "__CACHED_FORM_PARAMETERS";
|
||||||
|
protected Request myRequest;
|
||||||
|
|
||||||
|
public JettyAdapterSessionStore(Request request) {
|
||||||
|
this.myRequest = request; // for IDE/compilation purposes
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MultiMap<String> extractFormParameters(Request base_request) {
|
||||||
|
MultiMap<String> formParameters = new MultiMap<String>();
|
||||||
|
base_request.extractFormParameters(formParameters);
|
||||||
|
return formParameters;
|
||||||
|
}
|
||||||
|
protected void restoreFormParameters(MultiMap<String> j_post, Request base_request) {
|
||||||
|
base_request.setContentParameters(j_post);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean restoreRequest() {
|
||||||
|
HttpSession session = myRequest.getSession(false);
|
||||||
|
if (session == null) return false;
|
||||||
|
synchronized (session) {
|
||||||
|
String j_uri = (String) session.getAttribute(FormAuthenticator.__J_URI);
|
||||||
|
if (j_uri != null) {
|
||||||
|
// check if the request is for the same url as the original and restore
|
||||||
|
// params if it was a post
|
||||||
|
StringBuffer buf = myRequest.getRequestURL();
|
||||||
|
if (myRequest.getQueryString() != null)
|
||||||
|
buf.append("?").append(myRequest.getQueryString());
|
||||||
|
if (j_uri.equals(buf.toString())) {
|
||||||
|
String method = (String)session.getAttribute(JettyHttpFacade.__J_METHOD);
|
||||||
|
myRequest.setMethod(method);
|
||||||
|
MultivaluedHashMap<String, String> j_post = (MultivaluedHashMap<String, String>) session.getAttribute(CACHED_FORM_PARAMETERS);
|
||||||
|
if (j_post != null) {
|
||||||
|
myRequest.setContentType("application/x-www-form-urlencoded");
|
||||||
|
MultiMap<String> map = new MultiMap<String>();
|
||||||
|
for (String key : j_post.keySet()) {
|
||||||
|
for (String val : j_post.getList(key)) {
|
||||||
|
map.add(key, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
restoreFormParameters(map, myRequest);
|
||||||
|
}
|
||||||
|
session.removeAttribute(FormAuthenticator.__J_URI);
|
||||||
|
session.removeAttribute(JettyHttpFacade.__J_METHOD);
|
||||||
|
session.removeAttribute(FormAuthenticator.__J_POST);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveRequest() {
|
||||||
|
// remember the current URI
|
||||||
|
HttpSession session = myRequest.getSession();
|
||||||
|
synchronized (session) {
|
||||||
|
// But only if it is not set already, or we save every uri that leads to a login form redirect
|
||||||
|
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
|
||||||
|
StringBuffer buf = myRequest.getRequestURL();
|
||||||
|
if (myRequest.getQueryString() != null)
|
||||||
|
buf.append("?").append(myRequest.getQueryString());
|
||||||
|
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
|
||||||
|
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
|
||||||
|
|
||||||
|
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
|
||||||
|
MultiMap<String> formParameters = extractFormParameters(myRequest);
|
||||||
|
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
|
||||||
|
for (String key : formParameters.keySet()) {
|
||||||
|
for (Object value : formParameters.getValues(key)) {
|
||||||
|
map.add(key, (String) value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.setAttribute(CACHED_FORM_PARAMETERS, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.adapters.saml.jetty;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.Authentication;
|
||||||
|
import org.eclipse.jetty.server.HttpChannel;
|
||||||
|
import org.eclipse.jetty.server.Request;
|
||||||
|
import org.eclipse.jetty.server.UserIdentity;
|
||||||
|
import org.keycloak.adapters.jetty.spi.JettyUserSessionManagement;
|
||||||
|
import org.keycloak.adapters.spi.AdapterSessionStore;
|
||||||
|
import org.keycloak.adapters.saml.SamlDeployment;
|
||||||
|
import org.keycloak.adapters.spi.HttpFacade;
|
||||||
|
|
||||||
|
import javax.servlet.ServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class KeycloakSamlAuthenticator extends AbstractSamlAuthenticator {
|
||||||
|
|
||||||
|
public KeycloakSamlAuthenticator() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Request resolveRequest(ServletRequest req) {
|
||||||
|
return Request.getBaseRequest(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Authentication createAuthentication(UserIdentity userIdentity, final Request request) {
|
||||||
|
return new KeycloakAuthentication(getAuthMethod(), userIdentity) {
|
||||||
|
@Override
|
||||||
|
public void logout() {
|
||||||
|
logoutCurrent(request);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AdapterSessionStore createSessionTokenStore(Request request, SamlDeployment resolvedDeployment) {
|
||||||
|
return new JettyAdapterSessionStore(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JettySamlSessionStore createJettySamlSessionStore(Request request, HttpFacade facade, SamlDeployment resolvedDeployment) {
|
||||||
|
JettySamlSessionStore store;
|
||||||
|
store = new Jetty9SamlSessionStore(request, createSessionTokenStore(request, resolvedDeployment), facade, idMapper, new JettyUserSessionManagement(request.getSessionManager()), resolvedDeployment);
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak SAML Jetty Integration</name>
|
<name>Keycloak SAML Jetty Integration</name>
|
||||||
@@ -35,5 +35,6 @@
|
|||||||
<module>jetty8.1</module>
|
<module>jetty8.1</module>
|
||||||
<module>jetty9.1</module>
|
<module>jetty9.1</module>
|
||||||
<module>jetty9.2</module>
|
<module>jetty9.2</module>
|
||||||
|
<module>jetty9.3</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak SAML Client Adapter Modules</name>
|
<name>Keycloak SAML Client Adapter Modules</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak SAML Tomcat Integration</name>
|
<name>Keycloak SAML Tomcat Integration</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-saml-tomcat-integration-pom</artifactId>
|
<artifactId>keycloak-saml-tomcat-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-saml-tomcat-integration-pom</artifactId>
|
<artifactId>keycloak-saml-tomcat-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-saml-tomcat-integration-pom</artifactId>
|
<artifactId>keycloak-saml-tomcat-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-saml-tomcat-integration-pom</artifactId>
|
<artifactId>keycloak-saml-tomcat-integration-pom</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak SAML Wildfly Integration</name>
|
<name>Keycloak SAML Wildfly Integration</name>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<version>2.0.0.CR1-SNAPSHOT</version>
|
<version>2.2.1.Final</version>
|
||||||
<relativePath>../../../../pom.xml</relativePath>
|
<relativePath>../../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
Loaded 100 of 1655 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user