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

Updates for 1.0.0 release #11

Merged
merged 76 commits into from
Dec 16, 2021
Merged
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
dd8a047
updating KinD to v0.11.1
mlbiam Nov 21, 2021
5d6cd3a
for #5 removed dynamic audit since not in k8s anymore
mlbiam Nov 21, 2021
d8fb8b2
for #5 updating k8s pkg meant can't just pass in path to ca anymore
mlbiam Nov 21, 2021
0bdca9a
for #1 update node image
mlbiam Nov 21, 2021
b1088ef
for #5 updated dependencies
mlbiam Nov 22, 2021
15479d6
for #5 moved to latest to make easier to update with simple rebuild
mlbiam Nov 22, 2021
f109b62
for #5 fixed the label
mlbiam Nov 22, 2021
bb8a778
for #5 upgraded go
mlbiam Nov 22, 2021
64ee2d8
for #2 added success and failure logging
mlbiam Nov 25, 2021
d5367f6
for #2 added docs
mlbiam Nov 25, 2021
2d25986
for #3 functional code working and tested, need to integrate into proxy
mlbiam Dec 1, 2021
3b75de8
for #3 moved to k8s user.Info for better compat with codebase
mlbiam Dec 2, 2021
21764a1
made the subjectaccessreview more transaction based
mlbiam Dec 2, 2021
b0a08fd
made New consistent, used in tests
mlbiam Dec 2, 2021
9574d93
better handle go's cannonicalizing header names
mlbiam Dec 3, 2021
5d90c19
for #3 integrated into the proxy, made impersonation header checking …
mlbiam Dec 3, 2021
7e13847
for #3 integrate into the proxy's run
mlbiam Dec 8, 2021
f64f868
for #3 started updated e2e
mlbiam Dec 8, 2021
a54f85c
for #3 updating tests
mlbiam Dec 8, 2021
70ed81f
for #3 added rbac for subjectaccessreviews to test suite
mlbiam Dec 8, 2021
248714f
for #3 update test rbac
mlbiam Dec 8, 2021
81f55e0
for #3 set error messages
mlbiam Dec 8, 2021
b3761ae
for #3 body isn't matching
mlbiam Dec 8, 2021
c521633
for #3 update checks
mlbiam Dec 8, 2021
189db88
for #3 confused on checks
mlbiam Dec 8, 2021
40ca6c8
for #3 testing
mlbiam Dec 8, 2021
a636757
for #3 better failure reporting
mlbiam Dec 8, 2021
e50da04
for #3 fix error reporting
mlbiam Dec 8, 2021
4b0b7da
for #3 trying to isolate
mlbiam Dec 8, 2021
92a30ce
for #3 finally found issue
mlbiam Dec 8, 2021
66e0b6b
for #3 fix check
mlbiam Dec 8, 2021
4e89ca5
for #3 break out tests
mlbiam Dec 8, 2021
4bb6cfa
for #3 Added rbac bindings for better impersonation testing
mlbiam Dec 8, 2021
c6e9493
for #3 fix clusterrole
mlbiam Dec 8, 2021
35969b3
for #3 fix overlap of declaration
mlbiam Dec 8, 2021
ce417ee
for #3 add happy path
mlbiam Dec 8, 2021
0e777cc
for #3 fix test for happy path
mlbiam Dec 8, 2021
e3fa2c6
for #3 force extra names to lowercase for subjectaccessreview
mlbiam Dec 8, 2021
6295c90
for #3 fix test case
mlbiam Dec 8, 2021
28c5f78
for #3 don't check resource name for extra?
mlbiam Dec 8, 2021
9d07586
for #3 check if rbac issue is extra
mlbiam Dec 8, 2021
dd241b9
for #3 add support for successful impersonation
mlbiam Dec 8, 2021
c99018d
for #3 looking for success
mlbiam Dec 8, 2021
faf0081
for #3 add rbac for happy path
mlbiam Dec 8, 2021
9e534f4
for #3 fix error check
mlbiam Dec 9, 2021
3b04ce6
for #3 fix rbac in test
mlbiam Dec 9, 2021
11639b7
for #3 fix rbac
mlbiam Dec 9, 2021
68b123a
for #3 trying to debug
mlbiam Dec 9, 2021
13ee636
for #3 condensed inbound extras to single outbound header
mlbiam Dec 9, 2021
f5a875e
for #3 add extra to happy path
mlbiam Dec 9, 2021
5f6f86a
for #3 checking extra impersonation
mlbiam Dec 9, 2021
c9eb8e7
for #3 fixed subjectaccessreview for extras
mlbiam Dec 9, 2021
c32d5b3
for #3 need to let proxy impersonate extra for test
mlbiam Dec 9, 2021
254120f
for #3 updated docs and templates
mlbiam Dec 9, 2021
2cb1d02
get test to run
mlbiam Dec 14, 2021
7195fed
make test work
mlbiam Dec 14, 2021
3a08ebc
for #3 removing unneeded generate
mlbiam Dec 14, 2021
ebd8d9e
creating automated build
mlbiam Dec 14, 2021
3257ed1
update action
mlbiam Dec 14, 2021
3846126
fix branch name
mlbiam Dec 14, 2021
a90ca2a
fix go version
mlbiam Dec 14, 2021
8be0669
for #8 go version
mlbiam Dec 14, 2021
687f73e
for #8 make container locally
mlbiam Dec 14, 2021
1881f00
for #8 making easier to build with actions
mlbiam Dec 14, 2021
7908b54
for #8 added docker build and push
mlbiam Dec 14, 2021
faf4402
for #8 docker build isn't working from action
mlbiam Dec 14, 2021
5e6f0be
for #8 docker build can't pickup bin dir
mlbiam Dec 14, 2021
2628194
for #8 making the build consistent with docker_build
mlbiam Dec 14, 2021
d88c105
for #8 updated ignore to not ignore our binay
mlbiam Dec 14, 2021
1979994
for build #8 re-add test
mlbiam Dec 14, 2021
ffc61b2
for #9 switched dockerfile
mlbiam Dec 14, 2021
a6ccdef
for #8 update e2e
mlbiam Dec 14, 2021
44fcea0
for #2 strip off proxy IP from x-forwarded-for
mlbiam Dec 16, 2021
44944da
for #5 bumped dependencies again
mlbiam Dec 16, 2021
5e100b6
for #10 added files for auto-updates, updated docs, added changelog
mlbiam Dec 16, 2021
e8a54be
updates for all tasks
mlbiam Dec 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
for #2 added success and failure logging
  • Loading branch information
mlbiam committed Nov 25, 2021

Verified

This commit was signed with the committer’s verified signature.
markgov Mark Roberts
commit 64ee2d8f8a28c60836295af2a20f96a37a575eac
5 changes: 5 additions & 0 deletions pkg/proxy/handlers.go
Original file line number Diff line number Diff line change
@@ -165,18 +165,23 @@ func (p *Proxy) withImpersonateRequest(handler http.Handler) http.Handler {

// newErrorHandler returns a handler failed requests.
func (p *Proxy) newErrorHandler() func(rw http.ResponseWriter, r *http.Request, err error) {

unauthedHandler := audit.NewUnauthenticatedHandler(p.auditor, func(rw http.ResponseWriter, r *http.Request) {
klog.V(2).Infof("unauthenticated user request %s", r.RemoteAddr)
http.Error(rw, "Unauthorized", http.StatusUnauthorized)
})

return func(rw http.ResponseWriter, r *http.Request, err error) {

if err == nil {
klog.Error("error was called with no error")
http.Error(rw, "", http.StatusInternalServerError)
return
}

// regardless of reason, log failed auth
p.logFailedRequest(r)

switch err {

// Failed auth
34 changes: 34 additions & 0 deletions pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import (

const (
UserHeaderClientIPKey = "Remote-Client-IP"
timestampLayout = "2006-01-02T15:04:05-0700"
)

var (
@@ -216,10 +217,43 @@ func (p *Proxy) RoundTrip(req *http.Request) (*http.Response, error) {
// Set up impersonation request.
rt := transport.NewImpersonatingRoundTripper(*conf, p.clientTransport)

// Log the request
p.logSuccessfulRequest(req, conf)

// Push request through round trippers to the API server.
return rt.RoundTrip(req)
}

// logs the request
func (p *Proxy) logSuccessfulRequest(req *http.Request, conf *transport.ImpersonationConfig) {
remoteAddr := req.RemoteAddr
indexOfColon := strings.Index(remoteAddr, ":")
if indexOfColon > 0 {
remoteAddr = remoteAddr[0:indexOfColon]
}

inboundExtras := ""

if conf.Extra != nil {
for key, value := range conf.Extra {
inboundExtras += key + "=" + strings.Join(value, "|") + " "
}
}

fmt.Printf("[%s] AuSuccess src:[%s / % s] URI:%s inbound:[%s / %s /%s]\n", time.Now().Format(timestampLayout), remoteAddr, req.Header.Get(("x-forwarded-for")), req.RequestURI, conf.UserName, strings.Join(conf.Groups, "|"), inboundExtras)
}

// logs the failed request
func (p *Proxy) logFailedRequest(req *http.Request) {
remoteAddr := req.RemoteAddr
indexOfColon := strings.Index(remoteAddr, ":")
if indexOfColon > 0 {
remoteAddr = remoteAddr[0:indexOfColon]
}

fmt.Printf("[%s] AuFail src:[%s / % s] URI:%s\n", time.Now().Format(timestampLayout), remoteAddr, req.Header.Get(("x-forwarded-for")), req.RequestURI)
}

func (p *Proxy) reviewToken(rw http.ResponseWriter, req *http.Request) bool {
var remoteAddr string
req, remoteAddr = context.RemoteAddr(req)