-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49870be
commit 60f305c
Showing
16 changed files
with
306 additions
and
3 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2009,6 +2009,7 @@ public static enum Provider { | |
LINKEDIN, | ||
MASTODON, | ||
MICROSOFT, | ||
SLACK, | ||
SPOTIFY, | ||
STRAVA, | ||
TWITCH, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ation-tests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/SlackCodeFlowResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.SecurityContext; | ||
|
||
import io.quarkus.oidc.UserInfo; | ||
import io.quarkus.security.Authenticated; | ||
|
||
@Path("/slack") | ||
public class SlackCodeFlowResource { | ||
|
||
public record SlackResponseDto(String userPrincipalName, String userInfoEmail) { | ||
} | ||
|
||
@Inject | ||
UserInfo userInfo; | ||
|
||
@Authenticated | ||
@GET | ||
public SlackResponseDto get(SecurityContext securityContext) { | ||
return new SlackResponseDto(securityContext.getUserPrincipal().getName(), userInfo.getEmail()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
...n-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/SlackWiremockTestResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.containing; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.post; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; | ||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer; | ||
import com.github.tomakehurst.wiremock.matching.AnythingPattern; | ||
|
||
import io.quarkus.test.oidc.server.OidcWiremockTestResource; | ||
|
||
public class SlackWiremockTestResource implements Closeable { | ||
|
||
private static final Logger LOG = Logger.getLogger(SlackWiremockTestResource.class); | ||
private static final int PORT = 8188; | ||
private final WireMockServer server; | ||
|
||
SlackWiremockTestResource() throws IOException { | ||
var config = wireMockConfig().port(PORT).globalTemplating(true); | ||
this.server = new WireMockServer(config); | ||
LOG.info("Starting Slack mock on port " + PORT); | ||
this.server.start(); | ||
configureStubs(); | ||
} | ||
|
||
private void configureStubs() { | ||
server.stubFor( | ||
get(urlMatching("/.well-known/openid-configuration.*")) | ||
.willReturn(aResponse() | ||
.withHeader("Content-Type", "application/json") | ||
.withBody( | ||
""" | ||
{ | ||
"issuer": "https://server.example.com", | ||
"authorization_endpoint": "http://localhost:8188/openid/connect/authorize", | ||
"token_endpoint": "http://localhost:8188/api/openid.connect.token", | ||
"userinfo_endpoint": "http://localhost:8188/api/openid.connect.userInfo", | ||
"jwks_uri": "http://localhost:8188/openid/connect/keys", | ||
"scopes_supported": ["openid","profile","email"], | ||
"response_types_supported": ["code"], | ||
"response_modes_supported": ["form_post"], | ||
"grant_types_supported": ["authorization_code"], | ||
"subject_types_supported": ["public"], | ||
"id_token_signing_alg_values_supported": ["RS256"], | ||
"claims_supported": ["sub","auth_time","iss"], | ||
"claims_parameter_supported": false, | ||
"request_parameter_supported": false, | ||
"request_uri_parameter_supported": true, | ||
"token_endpoint_auth_methods_supported": ["client_secret_post","client_secret_basic"] | ||
} | ||
"""))); | ||
|
||
server.stubFor( | ||
get(urlMatching("/openid/connect/authorize.*")) | ||
.withQueryParam("response_type", equalTo("code")) | ||
.withQueryParam("client_id", equalTo("7925551513107.7922794171477")) | ||
.withQueryParam("scope", containing("openid")) | ||
.withQueryParam("scope", containing("email")) | ||
.withQueryParam("scope", containing("profile")) | ||
.withQueryParam("scope", containing("profile")) | ||
.withQueryParam("redirect_uri", equalTo("http://localhost:8081/slack")) | ||
.withQueryParam("state", new AnythingPattern()) | ||
.withQueryParam("team", equalTo("quarkus-oidc-slack-demo")) | ||
.willReturn(aResponse() | ||
.withStatus(302) | ||
.withHeader("Set-Cookie", "{{request.headers.Set-Cookie}}") | ||
.withHeader("Content-Type", "text/html") | ||
.withHeader("Location", "http://localhost:8081/slack?code=7917304849541.79239831" | ||
+ "24323.1f4c41812b286422cbce183a9f083fa58f7c2761c281c2be483a376694f56274&state" | ||
+ "={{request.query.state}}") | ||
.withBody(""))); | ||
|
||
server.stubFor( | ||
get(urlMatching("/openid/connect/keys.*")) | ||
.willReturn(aResponse() | ||
.withHeader("Set-Cookie", "{{request.headers.Set-Cookie}}") | ||
.withHeader("Content-Type", "application/json") | ||
.withBody( | ||
""" | ||
{ | ||
"keys": [ | ||
{ | ||
"kid": "1", | ||
"kty":"RSA", | ||
"n":"iJw33l1eVAsGoRlSyo-FCimeOc-AaZbzQ2iESA3Nkuo3TFb1zIkmt0kzlnWVGt48dkaIl13Vdefh9hqw_r9yNF8xZqX1fp0PnCWc5M_TX_ht5fm9y0TpbiVmsjeRMWZn4jr3DsFouxQ9aBXUJiu26V0vd2vrECeeAreFT4mtoHY13D2WVeJvboc5mEJcp50JNhxRCJ5UkY8jR_wfUk2Tzz4-fAj5xQaBccXnqJMu_1C6MjoCEiB7G1d13bVPReIeAGRKVJIF6ogoCN8JbrOhc_48lT4uyjbgnd24beatuKWodmWYhactFobRGYo5551cgMe8BoxpVQ4to30cGA0qjQ", | ||
"e":"AQAB" | ||
} | ||
] | ||
} | ||
"""))); | ||
|
||
server.stubFor( | ||
post(urlMatching("/api/openid\\.connect\\.token.*")) | ||
.willReturn(aResponse() | ||
.withHeader("Set-Cookie", "{{request.headers.Set-Cookie}}") | ||
.withHeader("Content-Type", "application/json") | ||
.withBody( | ||
""" | ||
{ | ||
"ok": true, | ||
"access_token": "xoxp-7925551513107-7925645662178-7911177365927-reduced", | ||
"token_type": "Bearer", | ||
"id_token": "%s", | ||
"state": "{{request.query.state}}" | ||
} | ||
""".formatted(OidcWiremockTestResource.getIdToken("Rosetta", | ||
"7925551513107.7922794171477", Map.of("name", "Rosetta")))))); | ||
|
||
server.stubFor( | ||
get(urlMatching("/api/openid\\.connect\\.userInfo.*")) | ||
.willReturn(aResponse() | ||
.withHeader("Set-Cookie", "{{request.headers.Set-Cookie}}") | ||
.withHeader("Content-Type", "application/json") | ||
.withBody( | ||
""" | ||
{ | ||
"ok": true, | ||
"sub": "U07TA484GLU", | ||
"https:\\/\\/slack.com\\/user_id": "U0reducedGLU", | ||
"https:\\/\\/slack.com\\/team_id": "T0reduced35", | ||
"email": "example@example.com", | ||
"email_verified": true, | ||
"date_email_verified": 1729712670, | ||
"name": "Michal No", | ||
"picture": "https:\\/\\/avatars.slack-edge.com\\/2024-10-23\\/7948436985680_reduced.png", | ||
"given_name": "Michal", | ||
"family_name": "No", | ||
"locale": "en-US", | ||
"https:\\/\\/slack.com\\/team_name": "quarkus-oidc-slack-demo-workspace", | ||
"https:\\/\\/slack.com\\/team_domain": "reduced-ipa4978", | ||
"https:\\/\\/slack.com\\/user_image_24": "https:\\/\\/avatars.slack-edge.com\\/2024-10-23\\/7948436985680_reduced_a64ea0fba9db9b46c773_24.png", | ||
"https:\\/\\/slack.com\\/team_image_34": "https:\\/\\/a.slack-edge.com\\/80588\\/img\\/avatars-teams\\/ava_7948436985680_reduced.png", | ||
"https:\\/\\/slack.com\\/team_image_default": true | ||
} | ||
"""))); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
server.stop(); | ||
LOG.info("Slack mock was shut down"); | ||
} | ||
} |
Oops, something went wrong.