Skip to content

Commit

Permalink
chore: rename frontier provider teams to group
Browse files Browse the repository at this point in the history
  • Loading branch information
Chief-Rishab committed Nov 19, 2023
1 parent a47f7cd commit c251f07
Show file tree
Hide file tree
Showing 9 changed files with 1,597 additions and 1,597 deletions.
16 changes: 8 additions & 8 deletions docs/docs/providers/frontier.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[Frontier](https://raystack-frontier.vercel.app/) by Raystack is a role-based cloud-native user management system and authorization server for your applications and API endpoints. With Frontier, you can assign roles to users or groups of users to configure policies that determine whether a particular user has the ability to perform a certain action on a given resource. Guardian supports access management to the following resources in Frontier:

1. Team
2. Project
3. Organization
1. Organization
2. Group
3. Project

## Compatible version of Frontier :

Expand Down Expand Up @@ -38,7 +38,7 @@ credentials:
allowed_account_types:
- user
resources:
- type: team
- type: group
policy:
id: policy_id
version: 1
Expand Down Expand Up @@ -98,9 +98,9 @@ resources:

### Frontier Resource Type

- team
- project
- organization
- group
- project

### Frontier Resource Permission

Expand All @@ -113,5 +113,5 @@ resources:
| project | app_project_owner | Project Owner |
| project | app_project_manager | Project Manager |
| project | app_project_member | Project Member |
| team | app_group_owner | Group Owner |
| team | app_group_member | Group Member |
| group | app_group_owner | Group Owner |
| group | app_group_member | Group Member |
78 changes: 39 additions & 39 deletions mocks/FrontierClient.go → mocks/Client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions plugins/providers/frontier/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ type Policy struct {
}

type Client interface {
GetTeams(orgID string) ([]*Team, error)
GetGroups(orgID string) ([]*Group, error)
GetProjects(orgID string) ([]*Project, error)
GetOrganizations() ([]*Organization, error)
GrantTeamAccess(team *Team, userId string, role string) error
RevokeTeamAccess(team *Team, userId string, role string) error
GrantGroupAccess(group *Group, userId string, role string) error
RevokeGroupAccess(group *Group, userId string, role string) error
GrantProjectAccess(project *Project, userId string, role string) error
RevokeProjectAccess(project *Project, userId string, role string) error
GrantOrganizationAccess(organization *Organization, userId string, role string) error
Expand Down Expand Up @@ -148,34 +148,34 @@ func (c *client) GetAdminsOfGivenResourceType(id string, resourceTypeEndPoint st
return userEmails, err
}

func (c *client) GetTeams(orgID string) ([]*Team, error) {
func (c *client) GetGroups(orgID string) ([]*Group, error) {
groupsEndpoint := fmt.Sprintf(groupsEndpoint, orgID)
req, err := c.newRequest(http.MethodGet, groupsEndpoint, nil, "")
if err != nil {
return nil, err
}

var teams []*Team
var groups []*Group
var response interface{}
if _, err := c.do(req, &response); err != nil {
return nil, err
}

if v, ok := response.(map[string]interface{}); ok && v[groupsConst] != nil {
err = mapstructure.Decode(v[groupsConst], &teams)
err = mapstructure.Decode(v[groupsConst], &groups)
}

for _, team := range teams {
admins, err := c.GetAdminsOfGivenResourceType(team.ID, groupsEndpoint)
for _, group := range groups {
admins, err := c.GetAdminsOfGivenResourceType(group.ID, groupsEndpoint)
if err != nil {
return nil, err
}
team.Admins = admins
group.Admins = admins
}

c.logger.Info("Fetch teams from request", "total", len(teams), req.URL)
c.logger.Info("Fetch groups from request", "total", len(groups), req.URL)

return teams, err
return groups, err
}

func (c *client) GetProjects(orgID string) ([]*Project, error) {
Expand Down Expand Up @@ -238,7 +238,7 @@ func (c *client) GetOrganizations() ([]*Organization, error) {
return organizations, err
}

func (c *client) GrantTeamAccess(resource *Team, userId string, role string) error {
func (c *client) GrantGroupAccess(resource *Group, userId string, role string) error {
body := make(map[string]string)
body["principal"] = fmt.Sprintf("%s:%s", "app/user", userId)
body["resource"] = fmt.Sprintf("%s:%s", "app/group", resource.ID)
Expand Down Expand Up @@ -301,7 +301,7 @@ func (c *client) GrantOrganizationAccess(resource *Organization, userId string,
return nil
}

func (c *client) RevokeTeamAccess(resource *Team, userId string, role string) error {
func (c *client) RevokeGroupAccess(resource *Group, userId string, role string) error {
endpoint := createPolicyEndpoint + "?groupId=" + resource.ID + "&userId=" + userId + "&roleId=" + role
req, err := c.newRequest(http.MethodGet, endpoint, "", "")
if err != nil {
Expand Down
Loading

0 comments on commit c251f07

Please sign in to comment.