kubernetes apiserver integration (#1063)

* sessions: support bearer tokens in authorization

* wip

* remove dead code

* refactor signed jwt code

* use function

* update per comments

* fix test
This commit is contained in:
Caleb Doxsey 2020-07-14 08:33:24 -06:00 committed by GitHub
parent 5f6a67e6eb
commit a70254ab76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 140 additions and 57 deletions

View file

@ -0,0 +1,23 @@
package header
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTokenFromHeader(t *testing.T) {
t.Run("pomerium type", func(t *testing.T) {
r, _ := http.NewRequest("GET", "http://localhost/some/url", nil)
r.Header.Set("Authorization", "Pomerium JWT")
v := TokenFromHeader(r, "Authorization", "Pomerium")
assert.Equal(t, "JWT", v)
})
t.Run("bearer type", func(t *testing.T) {
r, _ := http.NewRequest("GET", "http://localhost/some/url", nil)
r.Header.Set("Authorization", "Bearer Pomerium-JWT")
v := TokenFromHeader(r, "Authorization", "Pomerium")
assert.Equal(t, "JWT", v)
})
}