mirror of https://github.com/portainer/portainer
fix(app): skip authorizations in CE [EE-2423] (#6431)
* feat(app): check auth on ee only * refactor(features): load edition from env var * fix(containers): show empty message if no containerspull/6302/head^2
parent
2c4c638f46
commit
b588d901cf
|
@ -0,0 +1 @@
|
||||||
|
PORTAINER_EDITION=CE
|
|
@ -191,7 +191,8 @@ export function ContainersDatatable({
|
||||||
role={tbodyProps.role}
|
role={tbodyProps.role}
|
||||||
style={tbodyProps.style}
|
style={tbodyProps.style}
|
||||||
>
|
>
|
||||||
{page.map((row) => {
|
{page.length > 0 ? (
|
||||||
|
page.map((row) => {
|
||||||
prepareRow(row);
|
prepareRow(row);
|
||||||
const { key, className, role, style } = row.getRowProps();
|
const { key, className, role, style } = row.getRowProps();
|
||||||
return (
|
return (
|
||||||
|
@ -203,7 +204,14 @@ export function ContainersDatatable({
|
||||||
style={style}
|
style={style}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})
|
||||||
|
) : (
|
||||||
|
<tr>
|
||||||
|
<td colSpan={columns.length} className="text-center text-muted">
|
||||||
|
No container available.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { configApp } from './config';
|
||||||
import { init as initFeatureService } from './portainer/feature-flags/feature-flags.service';
|
import { init as initFeatureService } from './portainer/feature-flags/feature-flags.service';
|
||||||
import { Edition } from './portainer/feature-flags/enums';
|
import { Edition } from './portainer/feature-flags/enums';
|
||||||
|
|
||||||
initFeatureService(Edition.CE);
|
initFeatureService(Edition[process.env.PORTAINER_EDITION]);
|
||||||
|
|
||||||
angular
|
angular
|
||||||
.module('portainer', [
|
.module('portainer', [
|
||||||
|
|
|
@ -10,7 +10,7 @@ const state: ServiceState = {
|
||||||
features: <Record<FeatureId, Edition>>{},
|
features: <Record<FeatureId, Edition>>{},
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function init(edition: Edition = Edition.CE) {
|
export async function init(edition: Edition) {
|
||||||
// will be loaded on runtime
|
// will be loaded on runtime
|
||||||
const currentEdition = edition;
|
const currentEdition = edition;
|
||||||
const features = {
|
const features = {
|
||||||
|
|
|
@ -33,13 +33,20 @@ export function useUser() {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useAuthorizations(authorizations: string | string[]) {
|
export function useAuthorizations(
|
||||||
|
authorizations: string | string[],
|
||||||
|
adminOnlyCE = false
|
||||||
|
) {
|
||||||
const authorizationsArray =
|
const authorizationsArray =
|
||||||
typeof authorizations === 'string' ? [authorizations] : authorizations;
|
typeof authorizations === 'string' ? [authorizations] : authorizations;
|
||||||
|
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const { params } = useCurrentStateAndParams();
|
const { params } = useCurrentStateAndParams();
|
||||||
|
|
||||||
|
if (process.env.PORTAINER_EDITION === 'CE') {
|
||||||
|
return !adminOnlyCE || isAdmin(user);
|
||||||
|
}
|
||||||
|
|
||||||
const { endpointId } = params;
|
const { endpointId } = params;
|
||||||
if (!endpointId) {
|
if (!endpointId) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -118,6 +125,6 @@ export function UserProvider({ children }: UserProviderProps) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAdmin(user: UserViewModel): boolean {
|
function isAdmin(user?: UserViewModel | null) {
|
||||||
return user.Role === 1;
|
return !!user && user.Role === 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new Dotenv(),
|
new Dotenv({ defaults: true }),
|
||||||
new ESLintPlugin(),
|
new ESLintPlugin(),
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: './app/index.html',
|
template: './app/index.html',
|
||||||
|
|
Loading…
Reference in New Issue