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
func verifyJWT(publicKeyPath string, token string) (bool, error) { | |
t, err := jwt.Parse(token, func(token *jwt.Token) (i interface{}, err error) { | |
if token.Method != (jwt.SigningMethodRS256) { | |
return nil, fmt.Errorf("invalid signing method") | |
} | |
verifyBytes, err := ioutil.ReadFile(publicKeyPath) | |
if err != nil { | |
return nil, err | |
} | |
return jwt.ParseRSAPublicKeyFromPEM(verifyBytes) |
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
func createJWT(privateKeyPath string, algorithm string, expiration time.Duration) (string, error) { | |
claims := jwt.StandardClaims{ | |
Audience: "example", | |
ExpiresAt: time.Now().Add(expiration).Unix(), | |
IssuedAt: time.Now().Unix(), | |
} | |
keyBytes, err := ioutil.ReadFile(privateKeyPath) | |
if err != nil { | |
return "", err |
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
grpcurl -plaintext -proto=./proto/user.proto -d '{"id": 1}' <SERVICE EXTERNAL IP>:80 user.UserService/Get |
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
kubectl apply -f ./kubernetes |
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
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: grpc-example | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: grpc-example |
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
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: grpc-example | |
spec: | |
ports: | |
- port: 80 | |
targetPort: 9000 | |
protocol: TCP | |
name: http2 |
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
docker build -t grpc-example:v0.0.1 -f ./docker/Dockerfile . | |
docker tag grpc-example:v0.0.1 asia.gcr.io/<YOUR PROJECT_ID>/grpc-example:v0.0.1 | |
docker push asia.gcr.io/<YOUR PROJECT_ID>/grpc-example:v0.0.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
gcloud endpoints services deploy ./api_config.yaml ./proto/user.pb |
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
type: google.api.Service | |
config_version: 3 | |
name: user.endpoints.<YOUR PROJECT_ID>.cloud.goog | |
apis: | |
- name: user.UserService | |
usage: | |
rules: |
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
protoc --go_out=plugins=grpc:. ./proto/user.proto --descriptor_set_out=./proto/user.pb |
NewerOlder