Skip to content

Commit

Permalink
Fix dots in usernames issues (#1015)
Browse files Browse the repository at this point in the history
* fixes the dot in username ticket regexp

* test for dots and @
  • Loading branch information
mina1460 authored Jul 28, 2023
1 parent 1da76ed commit 5ac3ee4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/jujuapi/access_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
// (1)[group](2)[-](3)[alices-wonderland](10)[#member]
// So if a group, user, UUID, controller name comes in, it will always be index 3 for them
// and if a relation specifier is present, it will always be index 10
jujuURIMatcher = regexp.MustCompile(`([a-zA-Z0-9]*)(\-|\z)([a-zA-Z0-9-@]*)(\:|)([a-zA-Z0-9-@]*)(\/|)([a-zA-Z0-9-]*)(\.|)([a-zA-Z0-9-]*)([a-zA-Z#]*|\z)\z`)
jujuURIMatcher = regexp.MustCompile(`([a-zA-Z0-9]*)(\-|\z)([a-zA-Z0-9-@.]*)(\:|)([a-zA-Z0-9-@]*)(\/|)([a-zA-Z0-9-]*)(\.|)([a-zA-Z0-9-]*)([a-zA-Z#]*|\z)\z`)
)

// AddGroup creates a group within JIMMs DB for reference by OpenFGA.
Expand Down
11 changes: 11 additions & 0 deletions internal/jujuapi/access_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,17 @@ func (s *accessControlSuite) TestAddRelation(c *gc.C) {
err: false,
changesType: "group",
},
//Test username with dots and @ -> group
{
input: tuple{"user-" + "kelvin.lina.test@external", "member", "group-" + group.Name},
want: createTupleKey(
"user:"+"kelvin.lina.test@external",
"member",
"group:"+strconv.FormatUint(uint64(group.ID), 10),
),
err: false,
changesType: "group",
},
//Test group -> controller
{
input: tuple{"group-" + "test-group#member", "administrator", "controller-" + controller.UUID},
Expand Down

0 comments on commit 5ac3ee4

Please sign in to comment.