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

add rbac_permissions to current-user response + rbac_enabled to current-org response #2611

Merged
merged 12 commits into from
Jul 21, 2023

Conversation

joeyorlando
Copy link
Contributor

What this PR does

unblocks https://github.com/grafana/oncall-mobile-app/issues/152

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • CHANGELOG.md updated (or pr:no changelog PR label added if not required)

@joeyorlando joeyorlando added the pr:no public docs Added to a PR that does not require public documentation updates label Jul 21, 2023
@joeyorlando joeyorlando requested review from a team July 21, 2023 07:15
@joeyorlando
Copy link
Contributor Author

@imtoori you can use these as such:

GET /api/internal/v1/current_team/ (not aptly named imo, actually represents the currently authenticated user's organization)

{
    "pk": "OJLC8P3BPHABN",
    "name": "Self-Hosted Organization",
    "slack_team_identity": null,
    "slack_channel": null,
    "rbac_enabled": true,
    "is_resolution_note_required": false,
    "env_status": {
        "telegram_configured": true,
        "phone_provider": {
            "configured": true,
            "test_sms": false,
            "test_call": true,
            "verification_call": false,
            "verification_sms": true
        }
    },
    "banner": {
        "body": null,
        "title": null
    }
}

GET /api/internal/v1/user/ - I believe you're already using this one

{
    ...<other stuff>
    "role": 0,
    "rbac_permissions": [
        {
            "action": "grafana-oncall-app.alert-groups:read"
        },
        {
            "action": "grafana-oncall-app.alert-groups:write"
        },
        ...<big list of permissions>
    ]
}

Copy link
Member

@vstpme vstpme left a comment

Choose a reason for hiding this comment

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

LGTM

@vstpme
Copy link
Member

vstpme commented Jul 21, 2023

@joeyorlando I think current_team is used as the endpoint path because organization was called team in the past. I think a good solution would be to register the same view under an additional current_organization (or just organization) path, and update plugin & mobile app accordingly. It's probably out of the scope of this PR, but if it's a one line change consider adding it here so the mobile app uses the correct route right away.

@joeyorlando
Copy link
Contributor Author

I think a good solution would be to register the same view under an additional current_organization (or just organization) path, and update plugin & mobile app accordingly

I like this idea, especially because it's easier to deprecate current_team if the mobile app isn't already consuming it. will give it a go 👍

@joeyorlando joeyorlando requested a review from a team July 21, 2023 13:31
@@ -106,5 +108,3 @@
path(r"login/<backend>/", auth.overridden_login_slack_auth, name="slack-auth"),
path(r"complete/<backend>/", auth.overridden_complete_slack_auth, name="complete-slack-auth"),
]

urlpatterns += router.urls
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this line is essentially a duplicate of line 69 and can be removed:
Screenshot 2023-07-21 at 15 49 00

@joeyorlando
Copy link
Contributor Author

@grafana/grafana-oncall-frontend can I get some 👀 ?

the main changes here are renaming teamStore -> organizationStore. the naming of teamStore was a bit misleading as it represents an organization, just needed to be updated (grafanaTeamStore === "team store"). Also updated the API calls to move calls to /current_team/ to /organization/. /current_team/ will be deprecated in the near future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved from TeamStore. There were a few things on TeamStore that were also removed as they were no longer used:

  @observable
  redirectingToProperTeam = false;

  @observable.shallow
  teams: { [id: number]: Team[] } = {};


constructor(rootStore: RootStore) {
super(rootStore);
this.path = '/organization/';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was changed from /current_team/, see this change on the backend

Comment on lines +10 to +12
channel_chat_id: string;
channel_name: string;
discussion_group_chat_id: number; // TODO check if string
discussion_group_chat_id: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these two changed fields are actually strings (verified on the backend)

@@ -36,7 +35,6 @@ export interface User {
slack_login: string;
} | null;
post_onboarding_entry_allowed: any;
teams: Team[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not used

Comment on lines -83 to -105
userStore: UserStore = new UserStore(this);
cloudStore: CloudStore = new CloudStore(this);
directPagingStore: DirectPagingStore = new DirectPagingStore(this);
grafanaTeamStore: GrafanaTeamStore = new GrafanaTeamStore(this);
alertReceiveChannelStore: AlertReceiveChannelStore = new AlertReceiveChannelStore(this);
outgoingWebhookStore: OutgoingWebhookStore = new OutgoingWebhookStore(this);

outgoingWebhook2Store: OutgoingWebhook2Store = new OutgoingWebhook2Store(this);
alertReceiveChannelFiltersStore: AlertReceiveChannelFiltersStore = new AlertReceiveChannelFiltersStore(this);
escalationChainStore: EscalationChainStore = new EscalationChainStore(this);
escalationPolicyStore: EscalationPolicyStore = new EscalationPolicyStore(this);
teamStore: TeamStore = new TeamStore(this);
telegramChannelStore: TelegramChannelStore = new TelegramChannelStore(this);
slackStore: SlackStore = new SlackStore(this);
slackChannelStore: SlackChannelStore = new SlackChannelStore(this);
heartbeatStore: HeartbeatStore = new HeartbeatStore(this);
scheduleStore: ScheduleStore = new ScheduleStore(this);
userGroupStore: UserGroupStore = new UserGroupStore(this);
alertGroupStore: AlertGroupStore = new AlertGroupStore(this);
resolutionNotesStore: ResolutionNotesStore = new ResolutionNotesStore(this);
apiTokenStore: ApiTokenStore = new ApiTokenStore(this);
globalSettingStore: GlobalSettingStore = new GlobalSettingStore(this);
filtersStore: FiltersStore = new FiltersStore(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

typing here is redundant. these attributes are properly typed w/o the explicit typing.

@joeyorlando joeyorlando requested a review from vstpme July 21, 2023 14:26
@joeyorlando joeyorlando merged commit 3d70876 into dev Jul 21, 2023
@joeyorlando joeyorlando deleted the jorlando/add-rbac-permissions-to-user-response branch July 21, 2023 15:38
brojd pushed a commit that referenced this pull request Sep 18, 2024
…nt-org response (#2611)

# What this PR does

unblocks grafana/oncall-mobile-app#152

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants