forked from helidon-io/helidon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: tvallin <[email protected]>
- Loading branch information
Showing
3 changed files
with
62 additions
and
14 deletions.
There are no files selected for viewing
29 changes: 15 additions & 14 deletions
29
archetypes/helidon/src/main/archetype/mp/custom/files/application.oidc.yaml
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,15 +1,16 @@ | ||
- oidc: | ||
client-id: "client-id-of-this-service" | ||
# See [EncryptionFilter](https://helidon.io/docs/latest/apidocs/io.helidon.config.encryption/io/helidon/config/encryption/EncryptionFilter.html) for details about encrypting passwords in configuration files. | ||
client-secret: "client-secret-of-this-service" | ||
identity-uri: "http://your-tenant.identity-server.com" | ||
frontend-uri: "http://my-service:8080" | ||
audience: "http://my-service" | ||
cors: | ||
allow-origins: ["http://foo.com", "http://there.com"] | ||
allow-methods: ["PUT", "DELETE"] | ||
outbound: | ||
- name: "internal-services" | ||
hosts: ["*.example.org"] | ||
outbound-token: | ||
header: "X-Internal-Auth" | ||
# use a custom name, so it does not clash with other examples | ||
cookie-name: "OIDC_EXAMPLE_COOKIE" | ||
# support for "Authorization" header with bearer token | ||
header-use: true | ||
# the default redirect-uri, where the webserver listens on redirects from identity server | ||
redirect-uri: "/oidc/redirect" | ||
issuer: "https://tenant.some-server.com/oauth2/default" | ||
audience: "configured audience" | ||
client-id: "some client id" | ||
client-secret: "some client secret" | ||
identity-uri: "https://tenant.some-server.com/oauth2/default" | ||
frontend-uri: "http://localhost:7987" | ||
server-type: "@default" | ||
# We want to redirect to login page (and token can be received either through cookie or header) | ||
redirect: true |
27 changes: 27 additions & 0 deletions
27
...lidon/src/main/archetype/mp/custom/files/src/main/java/__pkg__/OidcResource.java.mustache
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,27 @@ | ||
package {{package}}; | ||
|
||
import io.helidon.security.SecurityContext; | ||
import io.helidon.security.annotations.Authenticated; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.Context; | ||
|
||
/** | ||
* A simple JAX-RS resource with a single GET method. | ||
*/ | ||
@Path("/test") | ||
public class OidcResource { | ||
/** | ||
* Hello world using security context. | ||
* @param securityContext context as established during login | ||
* @return a string with current username | ||
*/ | ||
@Authenticated | ||
@GET | ||
public String getIt(@Context SecurityContext securityContext) { | ||
return "Hello " + securityContext.userName(); | ||
} | ||
|
||
} |
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