Skip to content

Commit

Permalink
Fix the Unauthorized for the Rest API
Browse files Browse the repository at this point in the history
This correctly sets the auth header to the incoming context.
  • Loading branch information
khrm authored and tekton-robot committed Dec 10, 2024
1 parent 1d78646 commit ed85c09
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/api/server/v1alpha2/plugin/plugin_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func getBlobLogs(s *LogServer, writer io.Writer, parent string, rec *db.Record)
iter := bucket.List(&blob.ListOptions{
Prefix: strings.TrimPrefix(s.config.LOGS_PATH+fmt.Sprintf(defaultBlobPathParams, parent, rec.ResultName, rec.Name), "/"),
})
s.logger.Debugf("prefix: %s", strings.TrimPrefix(s.config.LOGS_PATH+"/"+fmt.Sprintf(defaultBlobPathParams, parent, rec.ResultName, rec.Name)+"/", "/"))
s.logger.Debugf("prefix: %s", strings.TrimPrefix(s.config.LOGS_PATH+fmt.Sprintf(defaultBlobPathParams, parent, rec.ResultName, rec.Name), "/"))
for {
obj, err := iter.Next(ctx)
if err == io.EOF {
Expand Down Expand Up @@ -407,7 +407,8 @@ func (s *LogServer) LogMux() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// TODO: Create a new log handler
ctx := r.Context()
ctx = metadata.AppendToOutgoingContext(ctx, "authorization", r.Header.Get("Authorization"))
md := metadata.New(map[string]string{"authorization": r.Header.Get("Authorization")})
ctx = metadata.NewIncomingContext(ctx, md)
parent := r.PathValue("parent")
if err := s.auth.Check(ctx, parent, auth.ResourceLogs, auth.PermissionGet); err != nil {
s.logger.Error(err)
Expand Down

0 comments on commit ed85c09

Please sign in to comment.