forked from spring-cloud-services-samples/animal-rescue
-
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.
Sso manifest update (spring-cloud-services-samples#40)
* Update manifest files for deploying an SSO enabled gateway to Kubernetes Add patch for using VMware harbor registry to host images * Update routes to match the config for TAS * Add README for SSO Co-authored-by: Yuxin Bai <ybai@pivotal.io>
- Loading branch information
1 parent
1d5ba72
commit 77b6ea7
Showing
15 changed files
with
179 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
*.ipr | ||
out/ | ||
scripts/out/ | ||
**/secrets/ |
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
...java/io/spring/cloud/samples/animalrescue/backend/UserNameJwtAuthenticationConverter.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.spring.cloud.samples.animalrescue.backend; | ||
|
||
import java.util.Collection; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.security.authentication.AbstractAuthenticationToken; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.oauth2.jwt.Jwt; | ||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; | ||
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter; | ||
|
||
class UserNameJwtAuthenticationConverter implements Converter<Jwt, AbstractAuthenticationToken> { | ||
|
||
private final Converter<Jwt, Collection<GrantedAuthority>> jwtGrantedAuthoritiesConverter | ||
= new JwtGrantedAuthoritiesConverter(); | ||
|
||
@Override | ||
public AbstractAuthenticationToken convert(Jwt jwt) { | ||
Collection<GrantedAuthority> authorities = this.jwtGrantedAuthoritiesConverter.convert(jwt); | ||
return new JwtAuthenticationToken(jwt, authorities, getUserName(jwt)); | ||
} | ||
|
||
private String getUserName(Jwt jwt) { | ||
return jwt.containsClaim("user_name") ? jwt.getClaimAsString("user_name") : jwt.getSubject(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
apiVersion: "tanzu.vmware.com/v1" | ||
kind: SpringCloudGateway | ||
metadata: | ||
name: gateway-demo | ||
spec: | ||
ssoEnabled: true | ||
routes: | ||
- id: animal-rescue-frontend-0 | ||
uri: http://animal-rescue-frontend.animal-rescue.svc.cluster.local | ||
ssoEnabled: true | ||
predicates: | ||
- Path=/rescue/login | ||
- Method=GET | ||
filters: | ||
- StripPrefix=1 | ||
- RedirectTo=302, /rescue | ||
order: 0 | ||
- id: animal-rescue-frontend-1 | ||
uri: http://animal-rescue-frontend.animal-rescue.svc.cluster.local | ||
predicates: | ||
- Path=/rescue/** | ||
- Method=GET | ||
filters: | ||
- StripPrefix=1 | ||
order: 1000 | ||
|
||
- id: animal-rescue-backend-0 | ||
uri: http://animal-rescue-backend.animal-rescue.svc.cluster.local | ||
predicates: | ||
- Path=/api/animals | ||
- Method=GET | ||
filters: | ||
- StripPrefix=1 | ||
# - RateLimit=2,10s | ||
- id: animal-rescue-backend-1 | ||
uri: http://animal-rescue-backend.animal-rescue.svc.cluster.local | ||
ssoEnabled: true | ||
tokenRelay: true | ||
predicates: | ||
- Path=/api/whoami | ||
- Method=GET | ||
filters: | ||
- StripPrefix=1 | ||
- id: animal-rescue-backend-2 | ||
uri: http://animal-rescue-backend.animal-rescue.svc.cluster.local | ||
ssoEnabled: true | ||
tokenRelay: true | ||
predicates: | ||
- Path=/api/animals/*/adoption-requests/** | ||
- Method=POST,PUT,DELETE | ||
filters: | ||
- StripPrefix=1 | ||
- id: animal-rescue-backend-3 | ||
uri: http://animal-rescue-backend.animal-rescue.svc.cluster.local | ||
predicates: | ||
- Path=/api/actuator/ | ||
filters: | ||
- StripPrefix=1 |
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,19 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
namespace: animal-rescue | ||
|
||
secretGenerator: | ||
- name: sso-credentials | ||
envs: | ||
- secrets/sso-credentials-for-backend.txt | ||
type: Opaque | ||
|
||
generatorOptions: | ||
disableNameSuffixHash: true | ||
|
||
resources: | ||
- namespace.yaml | ||
- animal-rescue-frontend.yaml | ||
- animal-rescue-backend.yaml | ||
- gateway-demo.yaml | ||
- gateway-demo-with-dynamic-routes.yaml |
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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,10 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
namespace: animal-rescue | ||
|
||
resources: | ||
- namespace.yaml | ||
- animal-rescue-frontend.yaml | ||
- animal-rescue-backend.yaml | ||
- gateway-demo.yaml | ||
- gateway-demo-with-dynamic-routes.yaml | ||
- base | ||
- overlays/sso-secret-for-gateway |
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,11 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
namespace: spring-cloud-gateway | ||
secretGenerator: | ||
- name: gateway-sso-credentials | ||
envs: | ||
- secrets/test-sso-credentials.txt | ||
type: Opaque | ||
|
||
generatorOptions: | ||
disableNameSuffixHash: true |
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 |
---|---|---|
|
@@ -19,4 +19,5 @@ build: | |
deploy: | ||
kustomize: | ||
paths: | ||
- k8s | ||
- k8s/base | ||
- k8s/overlays/sso-secret-for-gateway |