canonical / ofga

A wrapper library over the default OpenFGA client, packed with convenience methods for interacting with OpenFGA instances.
GNU Lesser General Public License v3.0
8 stars 4 forks source link

Support Juju user tags in entity strings #10

Closed babakks closed 1 year ago

babakks commented 1 year ago

Description

Juju user tags are formatted as user@domain, where user and domain may include . and + (user.go in juju/names):

    validUserNameSnippet = "[a-zA-Z0-9][a-zA-Z0-9.+-]*[a-zA-Z0-9]"
    validUserSnippet     = fmt.Sprintf("(?:%s(?:@%s)?)", validUserNameSnippet, validUserNameSnippet)
    validName            = regexp.MustCompile(fmt.Sprintf("^(?P<name>%s)(?:@(?P<domain>%s))?$", validUserNameSnippet, validUserNameSnippet))
    validUserName        = regexp.MustCompile("^" + validUserNameSnippet + "$")

In JIMM, we use an entire Juju user tag as an entity, so we'd need the ofga.Tuple type support those extra characters (plus @). This PR adds the extra characters to the RegExp pattern.

Engineering checklist

Check only items that apply

Merging instructions

The preferred way of merging: