Skip to content

Commit e805920

Browse files
skipihamir-suspect
andauthored
Add service account feature (#466)
## 📝 Description Combines front/backend changes for service account functionality. ## ✅ Checklist - [x] I have tested this change - [x] This change requires documentation update --------- Co-authored-by: Amir Hasanbasic <[email protected]> Co-authored-by: Amir Hasanbasic <[email protected]>
1 parent 98bb475 commit e805920

File tree

115 files changed

+8251
-981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+8251
-981
lines changed

ee/rbac/assets/permissions.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ permissions:
7070
description: "View the existing dashboards within the organization."
7171
- name: "organization.dashboards.manage"
7272
description: "Create new dashboard views."
73+
- name: "organization.service_accounts.view"
74+
description: "View service accounts within the organization."
75+
- name: "organization.service_accounts.manage"
76+
description: "Manage service accounts within the organization."
7377
project:
7478
- name: "project.view"
7579
description: "Access the project. This permission is needed to see any page within the project."

ee/rbac/assets/roles.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ roles:
3939
- "organization.custom_roles.view"
4040
- "organization.dashboards.view"
4141
- "organization.dashboards.manage"
42+
- "organization.service_accounts.view"
43+
- "organization.service_accounts.manage"
4244
- name: "Admin"
4345
description: "Admins can modify settings within the organization or any of its projects. However, they do not have access to billing information, and they cannot change general organization details, such as the organization name and URL."
4446
maps_to: "Admin"
@@ -77,6 +79,8 @@ roles:
7779
- "organization.dashboards.view"
7880
- "organization.dashboards.manage"
7981
- "project.delete"
82+
- "organization.service_accounts.view"
83+
- "organization.service_accounts.manage"
8084
- name: "Member"
8185
description: "Members can access the organization's homepage and the projects they are assigned to. However, they are not able to modify any settings."
8286
permissions:

ee/rbac/lib/internal_api/audit.pb.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ defmodule InternalApi.Audit.Event.Resource do
6767
field(:Okta, 17)
6868
field(:FlakyTests, 18)
6969
field(:RBACRole, 19)
70+
field(:ServiceAccount, 20)
7071
end
7172

7273
defmodule InternalApi.Audit.Event.Operation do

ee/rbac/lib/internal_api/rbac.pb.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule InternalApi.RBAC.SubjectType do
55

66
field(:USER, 0)
77
field(:GROUP, 1)
8+
field(:SERVICE_ACCOUNT, 2)
89
end
910

1011
defmodule InternalApi.RBAC.Scope do

ee/rbac/lib/internal_api/user.pb.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ defmodule InternalApi.User.User.CreationSource do
5656

5757
field(:NOT_SET, 0)
5858
field(:OKTA, 1)
59+
field(:SERVICE_ACCOUNT, 2)
5960
end
6061

6162
defmodule InternalApi.User.ListFavoritesRequest do

ee/rbac/lib/rbac/grpc_servers/rbac_server.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ defmodule Rbac.GrpcServers.RbacServer do
371371
total_pages: total_pages,
372372
members:
373373
Enum.map(subject_role_bindings, fn binding ->
374-
subject_type = if binding.type == "user", do: :USER, else: :GROUP
374+
subject_type = binding.type |> String.upcase() |> String.to_existing_atom()
375375

376376
%RBAC.ListMembersResponse.Member{
377377
subject: %RBAC.Subject{

front/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ RUN mix sentry_recompile && mix compile --warnings-as-errors
4545
# -- elixir stage
4646

4747
# -- node stage
48-
FROM node:16-alpine as node
48+
FROM node:16-alpine AS node
4949
WORKDIR /assets
5050
COPY front/assets/package.json front/assets/package-lock.json ./
5151
RUN npm set progress=false && npm install

front/assets/css/app-semaphore.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,6 +2795,8 @@ img { max-width: 100%; }
27952795
.b--indigo { border-color: #1570ff; }
27962796
.b--dark-indigo { border-color: #00359f; }
27972797
.b--orange { border-color: #fd7e14; }
2798+
.b--yellow { border-color: #FBC335; }
2799+
.b--blue { border-color: #2196F3; }
27982800
.b--purple { border-color: #8658d6; }
27992801
.b--dark-purple { border-color: #5122a5; }
28002802
.b--dark-brown { border-color: #974510; }
@@ -4585,6 +4587,7 @@ code, .code, pre {
45854587
.bg-washed-purple { background-color: #f3ecff; }
45864588
/* Yellows */
45874589
.yellow { color: #FBC335; }
4590+
.gold { color: #FBC335; }
45884591
.lightest-yellow { color: #fff3bf; }
45894592
.washed-yellow { color: #fffae4; }
45904593
.bg-yellow { background-color: #FBC335; }

front/assets/js/app.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { default as Agents} from "./agents";
6666
import { default as AddPeople } from "./people/add_people";
6767
import { default as EditPerson } from "./people/edit_person";
6868
import { default as SyncPeople } from "./people/sync_people";
69+
import { default as ServiceAccounts } from "./service_accounts";
6970
import { default as Report } from "./report";
7071

7172
import { InitializingScreen } from "./project_onboarding/initializing";
@@ -294,12 +295,23 @@ export var App = {
294295
GroupManagement.init();
295296
new Star();
296297

297-
const addPeopleAppRoot = document.getElementById("add-people");
298-
if (addPeopleAppRoot) {
299-
AddPeople({
300-
dom: addPeopleAppRoot,
301-
config: addPeopleAppRoot.dataset,
302-
});
298+
299+
// Initialize Preact apps
300+
const serviceAccountsEl = document.getElementById("service-accounts");
301+
if (serviceAccountsEl) {
302+
const config = JSON.parse(serviceAccountsEl.dataset.config);
303+
ServiceAccounts({ dom: serviceAccountsEl, config });
304+
}
305+
306+
const addPeopleEl = document.getElementById("add-people");
307+
if (addPeopleEl) {
308+
AddPeople({ dom: addPeopleEl, config: addPeopleEl.dataset });
309+
}
310+
311+
const syncPeopleEl = document.querySelector(".app-sync-people");
312+
if (syncPeopleEl) {
313+
const config = JSON.parse(syncPeopleEl.dataset.config);
314+
SyncPeople({ dom: syncPeopleEl, config });
303315
}
304316

305317
document.querySelectorAll(".app-edit-person").forEach((editPersonAppRoot) => {
@@ -516,6 +528,7 @@ export var App = {
516528

517529
window.Notice.init();
518530

531+
519532
$(document).on("click", ".x-select-on-click", function (event) {
520533
event.currentTarget.setSelectionRange(0, event.currentTarget.value.length);
521534
});

front/assets/js/people/add_people/index.tsx

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const App = () => {
4444
<span className="material-symbols-outlined mr2">person_add</span>
4545
{`Add people`}
4646
</button>
47-
<Modal isOpen={isOpen} close={() => close(false)} title="Add people">
47+
<Modal isOpen={isOpen} close={() => close(false)} title="Add new people" width="w-70-m">
4848
<AddNewUsers close={close}/>
4949
</Modal>
5050
</Fragment>
@@ -85,7 +85,7 @@ const AddNewUsers = (props: { close: (reload: boolean) => void, }) => {
8585
const Link = (props: { icon: VNode, title: string, }) => {
8686
return (
8787
<ActiveShadowLink
88-
className={`btn btn-secondary ${
88+
className={`flex-grow-1 btn btn-secondary ${
8989
currentProvider === provider ? `active` : ``
9090
}`}
9191
disabled={loading}
@@ -134,16 +134,9 @@ const AddNewUsers = (props: { close: (reload: boolean) => void, }) => {
134134
};
135135

136136
return (
137-
<div
138-
className="bg-white br3 shadow-1 w-90 w-70-m mw6 relative popup"
139-
style={{ top: `200px`, transform: `translate(-50%, 0)` }}
140-
>
141-
<div className="flex items-center justify-between ph4 pt4 mb3">
142-
<h2 className="f3 mb0">Add new people</h2>
143-
</div>
144-
137+
<div className="pa4">
145138
{userProviders.length > 1 && (
146-
<div className="mb3 button-group ph4 w-100 items-center justify-center">
139+
<div className="mb3 button-group w-100 items-center">
147140
{userProviders.map(userProviderBox)}
148141
</div>
149142
)}
@@ -158,7 +151,7 @@ const AddNewUsers = (props: { close: (reload: boolean) => void, }) => {
158151
return (
159152
<Fragment key={idx}>
160153
{loading && (
161-
<div className="ph4 pb4 tc">
154+
<div className="pb4 tc">
162155
<toolbox.Asset path="images/spinner.svg"/>
163156
</div>
164157
)}
@@ -280,7 +273,7 @@ const ProvideVia = (props: ProvideViaProps) => {
280273
return (
281274
<Fragment>
282275
<div className="ph4 pb4">{message}</div>
283-
<div className="flex justify-end items-center mt2 pb4 ph4">
276+
<div className="flex justify-end items-center mt2">
284277
<button
285278
className="btn btn-primary ml3"
286279
onClick={() => props?.onCancel(anyInvites)}
@@ -294,11 +287,11 @@ const ProvideVia = (props: ProvideViaProps) => {
294287

295288
return (
296289
<Fragment>
297-
<div className="ph4">
290+
<div className="">
298291
<label className="db mb2">Invite users to join your organization</label>
299292
</div>
300293
<div
301-
className="ph4 pv1 w-100"
294+
className="pv1 ph1 w-100"
302295
style={{ maxHeight: `400px`, overflow: `auto` }}
303296
>
304297
{!props.noManualInvite && (
@@ -370,7 +363,7 @@ const ProvideVia = (props: ProvideViaProps) => {
370363
</div>
371364

372365
{collaborators.length != 0 && (
373-
<div className="flex justify-end items-center mt2 pb4 ph4">
366+
<div className="flex justify-end items-center mt2">
374367
<a
375368
className="gray underline pointer"
376369
onClick={() => setSelectedCollaborators(collaborators)}
@@ -513,7 +506,7 @@ const ProvideViaEmail = (props: ProvideViaEmailProps) => {
513506

514507
return (
515508
<Fragment>
516-
<div className="ph4" style={{ maxHeight: `400px`, overflow: `auto` }}>
509+
<div className="ph1" style={{ maxHeight: `400px`, overflow: `auto` }}>
517510
{!arePeopleInvited && (
518511
<label className="db mb2">Email addresses and usernames</label>
519512
)}
@@ -593,7 +586,7 @@ const ProvideViaEmail = (props: ProvideViaEmailProps) => {
593586
))}
594587
</div>
595588
{arePeopleInvited && (
596-
<div className="flex justify-end pb4 ph4">
589+
<div className="flex justify-end">
597590
<button
598591
className="btn btn-primary"
599592
onClick={() => props?.onCancel(true)}
@@ -603,7 +596,7 @@ const ProvideViaEmail = (props: ProvideViaEmailProps) => {
603596
</div>
604597
)}
605598
{!arePeopleInvited && (
606-
<div className="flex justify-end pb4 ph4">
599+
<div className="flex justify-end">
607600
<button
608601
className="btn btn-secondary mr3"
609602
onClick={() => props?.onCancel(false)}

0 commit comments

Comments
 (0)