Skip to content

Commit

Permalink
Interceptor makes more sense in bifrost
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthb committed May 24, 2023
1 parent b093e91 commit 775f64c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/club/interceptor.go → interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

package club
package bifrost

import (
"context"
Expand All @@ -11,7 +11,7 @@ import (
"encoding/pem"
"net/http"

"github.com/RealImage/bifrost"
"github.com/RealImage/bifrost/pkg/club"
"github.com/google/uuid"
"golang.org/x/exp/slog"
)
Expand All @@ -34,10 +34,10 @@ func CtxClientID(ctx context.Context) (uuid.UUID, *x509.Certificate) {
// the request context.
func Interceptor(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
rctxHeader := r.Header.Get(RequestContextHeader)
rctxHeader := r.Header.Get(club.RequestContextHeader)
if rctxHeader != "" {
ctx := r.Context()
var rctx RequestContext
var rctx club.RequestContext
if err := json.Unmarshal([]byte(rctxHeader), &rctx); err != nil {
slog.ErrorCtx(ctx, "error unmarshaling request context", "err", err)
w.WriteHeader(http.StatusInternalServerError)
Expand All @@ -49,7 +49,7 @@ func Interceptor(next http.Handler) http.Handler {
w.WriteHeader(http.StatusInternalServerError)
return
}
uuid, cert, err := bifrost.ParseCertificate(block.Bytes)
uuid, cert, err := ParseCertificate(block.Bytes)
if err != nil {
slog.ErrorCtx(ctx, "error parsing client certificate", "err", err)
w.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit 775f64c

Please sign in to comment.