Sign inSign up

justdomepaul/goalkeeper

By justdomepaul

•Updated over 5 years ago

Easy to intercept gRPC request to authenticate metadata.

Image
0

1.4K

justdomepaul/goalkeeper repository overview

⁠goalKeeper

Easy to intercept gRPC request to authenticate metadata.

⁠author

Maxfocker ([email protected]⁠)

⁠included

dockerize⁠

⁠activity diagram

Imgur

⁠How to usage
⁠help
docker run --rm -ti justdomepaul/goalkeeper -timeout 60s /app/goalkeeper help
⁠normal proxy
docker run --rm -ti justdomepaul/goalkeeper -timeout 60s /app/goalkeeper server -p {goalkeeper port} -t {target address}
⁠basic proxy(default username/password: root/root)
docker run --rm -ti justdomepaul/goalkeeper -timeout 60s /app/goalkeeper server -p {goalkeeper port} -t {target address} --force-auth -a BASIC
⁠jwt proxy
docker run --rm -ti justdomepaul/goalkeeper -timeout 60s /app/goalkeeper server -p {goalkeeper port} -t {target address} --force-auth -a JWT --jwt-type {ES256/RS256/HS256/EES256/ERS256/EHS256} --jwt-key {private key string}
⁠gRPC proxy
docker run --rm -ti justdomepaul/goalkeeper -timeout 60s /app/goalkeeper server -p {goalkeeper port} -t {target address} --force-auth -a GRPC --auth-server {auth gRPC address}
⁠http proxy
docker run --rm -ti justdomepaul/goalkeeper -timeout 60s /app/goalkeeper server -p {goalkeeper port} -t {target address} --force-auth -a HTTP --auth-server {auth http address (include api path)}
⁠bbr limiter
docker run --rm -ti justdomepaul/goalkeeper -timeout 60s /app/goalkeeper server -p {goalkeeper port} -t {target address} --limiter --bbr
⁠client request metadata
authorization: Bearer {your jwt token or anything token} 
⁠auth gRPC proto

If you want to use gRPC proxy authenticate, follow this gRPC proto and implement to your gRPC server.

syntax = "proto3";
package auth;

option go_package = ".;auth";
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";

// Auth service
service Auth {
    rpc Ping(google.protobuf.Empty) returns (google.protobuf.Empty) {
        option (google.api.http) = {
            get: "/api/v1/auth/ping"
        };
    }
    rpc Authenticate(AuthenticateRequest) returns (google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/auth/authenticate"
            body: "*"
        };
    }
}

message AuthenticateRequest {
    string token = 1;
}
⁠gRPC build makefile
.DEFAULT_GOAL := help
.PHONY: help clean build

help: ## This help.
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

HOST = $(abspath .)
GRPC_SRC = $(notdir ${wildcard *.proto})
GPRC_DIST_GO = ./dist/go
GRPC_DOCKER = docker run --rm -u 1000 -v $(HOST):/workspace/auth -w /workspace/auth justdomepaul/protobuf:v3.12.4 $(1)
GRPC_DOCKER_EXECUTE = docker run -ti --rm -u 1000 -v $(HOST):/workspace/auth -w /workspace/auth justdomepaul/protobuf:v3.12.4 sh

clean: clean-grpc ## clean all generated files

clean-grpc: ## clean GRPC generated files
	@rm -rf $(GPRC_DIST_GO)

run: ## run execute
	@$(call GRPC_DOCKER_EXECUTE)

build: build-grpc-go-fast ## build all

build-grpc-go-fast: ## build gRPC GO fast
	$(info build gRPC GO)
	@mkdir -p ./$(GPRC_DIST_GO)
	$(eval INCLUDE := --descriptor_set_out=./dist/go/descriptor.protoset --include_source_info --include_imports -I=. -I=/go/pkg/mod -I=/go/pkg/mod/github.com/gogo/[email protected]/protobuf -I=/go/pkg/mod/github.com/gogo/[email protected]/ -I=/go/pkg/mod/github.com/grpc-ecosystem/[email protected]/)
	$(eval OUT_GO := --gofast_out=plugins=grpc,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/typesZ,paths=source_relative:$(GPRC_DIST_GO))
	$(eval CMD := protoc $(INCLUDE) $(OUT_GO) $(GRPC_SRC))
	@$(call GRPC_DOCKER, $(CMD))
⁠feature
⁠Change Log
  • v0.1.6 fix some code bug
  • v0.1.5 create ignoreList option, to ignore unnecessary authentication path
  • v0.1.4 create bbr rate limiter
  • v0.1.3 refactor metadata add new value use Set method replace Append method
  • v0.1.2 authenticate argument metadata add uri key-value, and extend GRPCAuthenticate request context include metadata.

⁠license

MIT

MIT License

Copyright (c) 2020 goalkeeper

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Tag summary

Content type

Image

Digest

Size

54 MB

Last updated

over 5 years ago

docker pull justdomepaul/goalkeeper