Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python SciKit #122

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14-alpine
FROM golang:1.14-alpine as build

WORKDIR /go/src/github.com/abutaha/aws-es-proxy
COPY . .
Expand All @@ -11,7 +11,7 @@ LABEL name="aws-es-proxy" \

RUN apk --no-cache add ca-certificates
WORKDIR /home/
COPY --from=0 /go/src/github.com/abutaha/aws-es-proxy/aws-es-proxy /usr/local/bin/
COPY --from=build /go/src/github.com/abutaha/aws-es-proxy/aws-es-proxy /usr/local/bin/

ENV PORT_NUM 9200
EXPOSE ${PORT_NUM}
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# ARCHIVED

We do not use AWS ElasticSearch (OpenSearch now) anymore


# aws-es-proxy

[![Docker Pulls](https://img.shields.io/docker/pulls/abutaha/aws-es-proxy.svg)](https://hub.docker.com/r/abutaha/aws-es-proxy/)
Expand Down
19 changes: 17 additions & 2 deletions aws-es-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"runtime"
"strings"
"time"
"encoding/base64"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
Expand Down Expand Up @@ -92,6 +93,10 @@ type proxy struct {
assumeRole string
}

type jwt_header struct {
Email string `json:"email"`
}

func newProxy(args ...interface{}) *proxy {

noRedirect := func(req *http.Request, via []*http.Request) error {
Expand Down Expand Up @@ -373,8 +378,18 @@ func (p *proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Println("Body: ")
fmt.Println(string(prettyBody.Bytes()))
} else {
log.Printf(" -> %s; %s; %s; %s; %d; %.3fs\n",
r.Method, r.RemoteAddr,
encoded_header := r.Header.Get("X-Amzn-Oidc-Data")
var jwtHeader jwt_header

if encoded_header != "" {
encoded_header_payload := strings.Split(encoded_header, ".")
// the payload is in the middle
jwt_header_bytes, _ := base64.StdEncoding.DecodeString(encoded_header_payload[1])
_ = json.Unmarshal(jwt_header_bytes, &jwtHeader)
}

log.Printf(" %s -> %s; %s; %s; %s; %d; %.3fs\n",
jwtHeader.Email, r.Method, r.RemoteAddr,
proxied.RequestURI(), query,
resp.StatusCode, requestEnded.Seconds())
}
Expand Down