fix: remove migrated, and /org endpoint (#44788)

* fix: remove migrated, and /org endpoint

* Update pkg/api/index.go
This commit is contained in:
Eric Leijonmarck 2022-02-02 16:32:37 +01:00 committed by GitHub
parent 9e6b9215ab
commit 1dd2579528
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 21 deletions

View File

@ -144,9 +144,8 @@ func (hs *HTTPServer) getAppLinks(c *models.ReqContext) ([]*dtos.NavLink, error)
}
func enableServiceAccount(hs *HTTPServer, c *models.ReqContext) bool {
return c.OrgRole == models.ROLE_ADMIN &&
hs.Features.IsEnabled(featuremgmt.FlagServiceAccounts) &&
hs.serviceAccountsService.Migrated(c.Req.Context(), c.OrgId)
return (c.OrgRole == models.ROLE_ADMIN || (hs.Cfg.EditorsCanAdmin && c.OrgRole == models.ROLE_EDITOR)) &&
hs.Features.IsEnabled(featuremgmt.FlagServiceAccounts)
}
func enableTeams(hs *HTTPServer, c *models.ReqContext) bool {

View File

@ -13,19 +13,16 @@ var (
Description: "encrypt secrets",
State: FeatureStateBeta,
},
{
Name: "httpclientprovider_azure_auth",
Description: "use http client for azure auth",
State: FeatureStateBeta,
},
{
Name: "service-accounts",
Description: "support service accounts",
State: FeatureStateBeta,
RequiresLicense: true,
Name: "service-accounts",
Description: "support service accounts",
State: FeatureStateBeta,
},
{
Name: "database_metrics",
Description: "Add prometheus metrics for database tables",

View File

@ -47,7 +47,7 @@ func (api *ServiceAccountsAPI) RegisterAPIEndpoints(
}
auth := acmiddleware.Middleware(api.accesscontrol)
api.RouterRegister.Group("/api/org/serviceaccounts", func(serviceAccountsRoute routing.RouteRegister) {
api.RouterRegister.Group("/api/serviceaccounts", func(serviceAccountsRoute routing.RouteRegister) {
serviceAccountsRoute.Get("/", auth(middleware.ReqOrgAdmin, accesscontrol.EvalPermission(serviceaccounts.ActionRead, serviceaccounts.ScopeAll)), routing.Wrap(api.ListServiceAccounts))
serviceAccountsRoute.Get("/:serviceAccountId", auth(middleware.ReqOrgAdmin, accesscontrol.EvalPermission(serviceaccounts.ActionRead, serviceaccounts.ScopeID)), routing.Wrap(api.RetrieveServiceAccount))
serviceAccountsRoute.Delete("/:serviceAccountId", auth(middleware.ReqOrgAdmin, accesscontrol.EvalPermission(serviceaccounts.ActionDelete, serviceaccounts.ScopeID)), routing.Wrap(api.DeleteServiceAccount))

View File

@ -24,7 +24,7 @@ import (
)
var (
serviceaccountIDPath = "/api/org/serviceaccounts/%v"
serviceaccountIDPath = "/api/serviceaccounts/%v"
)
// test the accesscontrol endpoints

View File

@ -61,9 +61,3 @@ func (sa *ServiceAccountsService) DeleteServiceAccount(ctx context.Context, orgI
}
return sa.store.DeleteServiceAccount(ctx, orgID, serviceAccountID)
}
func (sa *ServiceAccountsService) Migrated(ctx context.Context, orgID int64) bool {
// TODO: implement migration logic
// change this to return true for development of service accounts page
return false
}

View File

@ -9,7 +9,6 @@ import (
type Service interface {
CreateServiceAccount(ctx context.Context, saForm *CreateServiceaccountForm) (*models.User, error)
DeleteServiceAccount(ctx context.Context, orgID, serviceAccountID int64) error
Migrated(ctx context.Context, orgID int64) bool
}
type Store interface {

View File

@ -32,7 +32,7 @@ const mapDispatchToProps = {
const connector = connect(mapStateToProps, mapDispatchToProps);
const ServiceAccountsListPage2: React.FC<Props> = ({ loadServiceAccounts, navModel, serviceAccounts, isLoading }) => {
const ServiceAccountsListPage: React.FC<Props> = ({ loadServiceAccounts, navModel, serviceAccounts, isLoading }) => {
const styles = useStyles2(getStyles);
useEffect(() => {
@ -184,4 +184,4 @@ const getStyles = (theme: GrafanaTheme2) => {
};
};
export default connector(ServiceAccountsListPage2);
export default connector(ServiceAccountsListPage);

View File

@ -3,7 +3,7 @@ import { getBackendSrv } from '@grafana/runtime';
import { ServiceAccountDTO } from 'app/types';
import { serviceAccountLoaded, serviceAccountsLoaded } from './reducers';
const BASE_URL = `/api/org/serviceaccounts`;
const BASE_URL = `/api/serviceaccounts`;
export function loadServiceAccount(id: number): ThunkResult<void> {
return async (dispatch) => {