Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving access related logic from jujuapi to jimm. #1122

Merged
merged 6 commits into from
Jan 9, 2024

Conversation

alesstimec
Copy link
Collaborator

Description

Moves access related logic from the jujuapi package to jimm package.

Engineering checklist

Check only items that apply

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

Notes for code reviewers

Copy link

github-actions bot commented Jan 3, 2024

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git commit -S --amend --no-edit) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

@alesstimec alesstimec force-pushed the move-to-jimm-pkg-01 branch from d7a43a9 to 09802de Compare January 3, 2024 09:14
internal/jimm/jimm.go Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe some of the methods on the JIMM interface were due to logic in jujuapi that should have been in jimm, like DB() and AuthorizationClient(), can those now be removed from the JIMM interface?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a followup

// (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`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this pattern can use some polishing (e.g., removing unnecessary escapes, or simplifying (\:|) with (:?)), but considering the goal of the PR, I think it's best to leave it as is.

user := dbmodel.User{
Username: username,
}
if err := j.Database.GetUser(ctx, &user); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In several (if not many) places we do this manually. I mean, we fetch a user from the database and wrap it as a openfga.User struct instance. Maybe in a follow-up PR, we refactor those cases toward using this method.

@alesstimec alesstimec force-pushed the move-to-jimm-pkg-01 branch from d30ca48 to 7b052c6 Compare January 9, 2024 13:44
Copy link

github-actions bot commented Jan 9, 2024

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git commit -S --amend --no-edit) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

@alesstimec alesstimec force-pushed the move-to-jimm-pkg-01 branch from 7b052c6 to ca228d7 Compare January 9, 2024 13:44
@alesstimec alesstimec merged commit 77cbc14 into canonical:v3 Jan 9, 2024
4 checks passed
@kian99 kian99 mentioned this pull request Nov 26, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants