-
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.
Merge pull request #6348 from pedroigor/issue-4448
[fixes #4448] - OIDC Multi-tenancy Support
- Loading branch information
Showing
29 changed files
with
1,213 additions
and
327 deletions.
There are no files selected for viewing
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
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
12 changes: 7 additions & 5 deletions
12
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/IdTokenCredential.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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
package io.quarkus.oidc; | ||
|
||
import io.quarkus.security.credential.TokenCredential; | ||
import io.quarkus.oidc.runtime.ContextAwareTokenCredential; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class IdTokenCredential extends ContextAwareTokenCredential { | ||
|
||
public class IdTokenCredential extends TokenCredential { | ||
public IdTokenCredential() { | ||
this(null); | ||
this(null, null); | ||
} | ||
|
||
public IdTokenCredential(String token) { | ||
super(token, "id_token"); | ||
public IdTokenCredential(String token, RoutingContext context) { | ||
super(token, "id_token", context); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/TenantConfigResolver.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,24 @@ | ||
package io.quarkus.oidc; | ||
|
||
import io.quarkus.oidc.runtime.OidcTenantConfig; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
/** | ||
* <p> | ||
* A tenant resolver is responsible for resolving the {@link OidcTenantConfig} for tenants, dynamically. | ||
* | ||
* <p> | ||
* Instead of implementing a {@link TenantResolver} that maps the tenant configuration based on an identifier and its | ||
* corresponding entry in the application configuration file, beans implementing this interface can dynamically construct the | ||
* tenant configuration without having to define each tenant in the application configuration file. | ||
*/ | ||
public interface TenantConfigResolver { | ||
|
||
/** | ||
* Returns a {@link OidcTenantConfig} given a {@code RoutingContext}. | ||
* | ||
* @param context the routing context | ||
* @return the tenant configuration. If {@code null}, indicates that the default configuration/tenant should be chosen | ||
*/ | ||
OidcTenantConfig resolve(RoutingContext context); | ||
} |
18 changes: 18 additions & 0 deletions
18
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/TenantResolver.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,18 @@ | ||
package io.quarkus.oidc; | ||
|
||
import io.vertx.ext.web.RoutingContext; | ||
|
||
/** | ||
* A tenant resolver is responsible for resolving tenants dynamically so that the proper configuration can be used accordingly. | ||
*/ | ||
public interface TenantResolver { | ||
|
||
/** | ||
* Returns a tenant identifier given a {@code RoutingContext}, where the identifier will be used to choose the proper | ||
* configuration during runtime. | ||
* | ||
* @param context the routing context | ||
* @return the tenant identifier. If {@code null}, indicates that the default configuration/tenant should be chosen | ||
*/ | ||
String resolve(RoutingContext context); | ||
} |
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
18 changes: 18 additions & 0 deletions
18
...sions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/ContextAwareTokenCredential.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,18 @@ | ||
package io.quarkus.oidc.runtime; | ||
|
||
import io.quarkus.security.credential.TokenCredential; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class ContextAwareTokenCredential extends TokenCredential { | ||
|
||
private RoutingContext context; | ||
|
||
protected ContextAwareTokenCredential(String token, String type, RoutingContext context) { | ||
super(token, type); | ||
this.context = context; | ||
} | ||
|
||
RoutingContext getContext() { | ||
return context; | ||
} | ||
} |
Oops, something went wrong.