Skip to content

Commit

Permalink
feat: provide company name and tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Oct 23, 2024
1 parent de8b3aa commit 371f367
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions internal/api/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func (a API) ACLv2(c *fiber.Ctx) error {
span.SetAttributes(
attribute.String("access", request.Action),
attribute.String("topic", request.Topic),
attribute.String("username", request.Username),
attribute.String("password", request.Password),
attribute.String("authenticator", auth.GetCompany()),
)

Expand All @@ -85,7 +87,7 @@ func (a API) ACLv2(c *fiber.Ctx) error {
span.RecordError(err)
}

a.Metrics.ACLFailed(vendor, err)
a.Metrics.ACLFailed(auth.GetCompany(), err)

var tnaErr authenticator.TopicNotAllowedError

Expand All @@ -106,7 +108,7 @@ func (a API) ACLv2(c *fiber.Ctx) error {

logger.
Info("acl ok")
a.Metrics.ACLSuccess(vendor)
a.Metrics.ACLSuccess(auth.GetCompany())

return c.Status(http.StatusOK).JSON(ACLResponse{
Result: "allow",
Expand Down
6 changes: 4 additions & 2 deletions internal/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ func (a API) Authv2(c *fiber.Ctx) error {
attribute.String("authenticator", auth.GetCompany()),
attribute.String("cliend-id", request.ClientID),
attribute.String("source", source),
attribute.String("username", request.Username),
attribute.String("password", request.Password),
)

if err := auth.Auth(ctx, token); err != nil {
span.RecordError(err)
a.Metrics.AuthFailed(vendor, source, err)
a.Metrics.AuthFailed(auth.GetCompany(), source, err)

if !errors.Is(err, jwt.ErrTokenExpired) {
logger.
Expand All @@ -91,7 +93,7 @@ func (a API) Authv2(c *fiber.Ctx) error {

logger.
Info("auth ok")
a.Metrics.AuthSuccess(vendor, source)
a.Metrics.AuthSuccess(auth.GetCompany(), source)

return c.Status(http.StatusOK).JSON(AuthResponse{
Result: "allow",
Expand Down

0 comments on commit 371f367

Please sign in to comment.