authorize: use opa for policy engine (#474)

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
Bobby DeSimone 2020-02-02 11:18:22 -08:00 committed by GitHub
parent 111aa8f4d5
commit 2f13488598
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 1022 additions and 872 deletions

View file

@ -42,16 +42,16 @@ func NewStore(enc encoding.Unmarshaler, headerType string) *Store {
}
// LoadSession tries to retrieve the token string from the Authorization header.
func (as *Store) LoadSession(r *http.Request) (*sessions.State, error) {
cipherText := TokenFromHeader(r, as.authHeader, as.authType)
if cipherText == "" {
return nil, sessions.ErrNoSessionFound
func (as *Store) LoadSession(r *http.Request) (*sessions.State, string, error) {
jwt := TokenFromHeader(r, as.authHeader, as.authType)
if jwt == "" {
return nil, "", sessions.ErrNoSessionFound
}
var session sessions.State
if err := as.encoder.Unmarshal([]byte(cipherText), &session); err != nil {
return nil, sessions.ErrMalformed
if err := as.encoder.Unmarshal([]byte(jwt), &session); err != nil {
return nil, "", sessions.ErrMalformed
}
return &session, nil
return &session, jwt, nil
}
// TokenFromHeader retrieves the value of the authorization header from a given