Skip to content

Commit

Permalink
feat: change the way of converting jwt fields to string
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Nov 30, 2024
1 parent 3ad0457 commit 6ebc162
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions internal/authenticator/manual_authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/golang-jwt/jwt/v5"
"github.com/hashicorp/hcl/hcl/strconv"

Check failure on line 8 in internal/authenticator/manual_authenticator.go

View workflow job for this annotation

GitHub Actions / test

missing go.sum entry for module providing package github.com/hashicorp/hcl/hcl/strconv (imported by github.com/snapp-incubator/soteria/internal/authenticator); to add:
"github.com/snapp-incubator/soteria/internal/config"
"github.com/snapp-incubator/soteria/internal/topics"
"github.com/snapp-incubator/soteria/pkg/acl"
Expand Down Expand Up @@ -99,13 +100,13 @@ func (a ManualAuthenticator) ACL(
return false, ErrIssNotFound
}

issuer := fmt.Sprintf("%v", claims[a.JWTConfig.IssName])
issuer := strconv.ToString(claims[a.JWTConfig.IssName])

if claims[a.JWTConfig.SubName] == nil {
return false, ErrSubNotFound
}

sub := fmt.Sprintf("%v", claims[a.JWTConfig.SubName])
sub := strconv.ToString(claims[a.JWTConfig.SubName])

topicTemplate := a.TopicManager.ParseTopic(topic, issuer, sub, map[string]any(claims))
if topicTemplate == nil {
Expand Down
4 changes: 3 additions & 1 deletion internal/topics/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/speps/go-hashids/v2"
regexp "github.com/wasilibs/go-re2"
"go.uber.org/zap"

jwtstrconv "github.com/snapp-incubator/soteria/pkg/strconv"
)

const (
Expand Down Expand Up @@ -103,7 +105,7 @@ func (t *Manager) ParseTopic(topic, iss, sub string, claims map[string]any) *Tem
fields := make(map[string]string)

for k, v := range claims {
fields[k] = fmt.Sprintf("%v", v)
fields[k] = jwtstrconv.ToString(v)
}

fields["iss"] = iss
Expand Down

0 comments on commit 6ebc162

Please sign in to comment.