Skip to content

Commit

Permalink
Added godoc
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jan 19, 2024
1 parent dc6b219 commit 282c174
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/jimm/service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (j *JIMM) AddServiceAccount(ctx context.Context, u *openfga.User, clientId
return nil
}

// GrantServiceAccountAccess creates an administrator relation between the tags provided
// and the service account. The provided tags must be users or groups (with the member relation)
// otherwise OpenFGA will report an error.
func (j *JIMM) GrantServiceAccountAccess(ctx context.Context, u *openfga.User, svcAccTag jimmnames.ServiceAccountTag, tags []*ofganames.Tag) error {
op := errors.Op("jimm.GrantServiceAccountAccess")
tuples := make([]openfga.Tuple, 0, len(tags))
Expand Down
2 changes: 2 additions & 0 deletions internal/jujuapi/service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func (r *controllerRoot) ListServiceAccountCredentials(ctx context.Context, req
return getIdentityCredentials(ctx, targetUser, r.jimm, req.CloudCredentialArgs)
}

// GrantServiceAccountAccess is the method handler for granting new users/groups with access
// to service accounts.
func (r *controllerRoot) GrantServiceAccountAccess(ctx context.Context, req apiparams.GrantServiceAccountAccess) error {
const op = errors.Op("jujuapi.GrantServiceAccountAccess")

Expand Down
1 change: 1 addition & 0 deletions internal/openfga/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (u *User) IsModelWriter(ctx context.Context, resource names.ModelTag) (bool
return isWriter, nil
}

// IsServiceAccountAdmin returns true if the user has administrator relation to the service account.
func (u *User) IsServiceAccountAdmin(ctx context.Context, clientID jimmnames.ServiceAccountTag) (bool, error) {
isAdmin, err := checkRelation(ctx, u, clientID, ofganames.AdministratorRelation)
if err != nil {
Expand Down

0 comments on commit 282c174

Please sign in to comment.