forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TenantHttps.java
39 lines (32 loc) · 1.09 KB
/
TenantHttps.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package io.quarkus.it.keycloak;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import io.quarkus.oidc.OidcSession;
import io.quarkus.security.Authenticated;
import io.vertx.ext.web.RoutingContext;
@Path("/tenant-https")
public class TenantHttps {
@Inject
OidcSession session;
@Inject
RoutingContext routingContext;
@GET
@Authenticated
public String getTenant() {
return session.getTenantId() + (routingContext.get("reauthenticated") != null ? ":reauthenticated" : "");
}
@GET
@Path("query")
@Authenticated
public String getTenantWithQuery(@QueryParam("code") String value) {
return getTenant() + "?code=" + value + "&expiresAt=" + session.expiresAt().getEpochSecond()
+ "&expiresInDuration=" + session.validFor().getSeconds();
}
@GET
@Path("error")
public String getError(@QueryParam("error") String error, @QueryParam("error_description") String errorDescription) {
return "error: " + error + ", error_description: " + errorDescription;
}
}