Skip to content

Commit

Permalink
[FIX] Keyban now correctly checks the master key validity (#425)
Browse files Browse the repository at this point in the history
Keyban just didn't work. There was a strange channel check while all that was required was to check the validity of the master key. See straighforward code change, for more info.
  • Loading branch information
Florimond authored Sep 9, 2024
1 parent 996fa4a commit 74e6649
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions internal/service/keyban/keyban.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ package keyban

import (
"encoding/json"
"fmt"
"regexp"

"github.com/emitter-io/emitter/internal/errors"
"github.com/emitter-io/emitter/internal/event"
"github.com/emitter-io/emitter/internal/security"
"github.com/emitter-io/emitter/internal/service"
"github.com/kelindar/binary"
)

var (
Expand Down Expand Up @@ -53,11 +50,9 @@ func (s *Service) OnRequest(c service.Conn, payload []byte) (service.Response, b
return errors.ErrBadRequest, false
}

// Decrypt the secret key and make sure it's not expired and is a master key
_, secretKey, ok := s.auth.Authorize(security.ParseChannel(
binary.ToBytes(fmt.Sprintf("%s/emitter/", message.Secret)),
), security.AllowMaster)
if !ok || secretKey.IsExpired() || !secretKey.IsMaster() {
// Decrypt the secret/master key and make sure it's not expired
secretKey, err := s.keygen.DecryptKey(message.Secret)
if err != nil || secretKey.IsExpired() || !secretKey.IsMaster() {
return errors.ErrUnauthorized, false
}

Expand Down

0 comments on commit 74e6649

Please sign in to comment.