-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b89b279
commit 3752032
Showing
17 changed files
with
258 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- | ||
-- Copyright (c) 2025 SUSE LLC | ||
-- | ||
-- This software is licensed to you under the GNU General Public License, | ||
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
-- along with this software; if not, see | ||
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
-- | ||
|
||
CREATE SCHEMA access; | ||
COMMENT ON SCHEMA access IS 'Contains the entities for RBAC'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- | ||
-- Copyright (c) 2025 SUSE LLC | ||
-- | ||
-- This software is licensed to you under the GNU General Public License, | ||
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
-- along with this software; if not, see | ||
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
-- | ||
|
||
CREATE TABLE access.endpoint ( | ||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | ||
class_method VARCHAR NOT NULL, | ||
endpoint VARCHAR NOT NULL, | ||
http_method VARCHAR NOT NULL, | ||
scope CHAR(1) NOT NULL | ||
CHECK (scope in ('A', 'W')), | ||
authorized BOOLEAN NOT NULL DEFAULT true, | ||
created TIMESTAMPTZ NOT NULL DEFAULT (current_timestamp), | ||
modified TIMESTAMPTZ NOT NULL DEFAULT (current_timestamp) | ||
); | ||
|
||
CREATE UNIQUE INDEX endpoint_endpoint_http_method_uq | ||
ON access.endpoint(endpoint, http_method); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- | ||
-- Copyright (c) 2025 SUSE LLC | ||
-- | ||
-- This software is licensed to you under the GNU General Public License, | ||
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
-- along with this software; if not, see | ||
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
-- | ||
|
||
CREATE TABLE access.endpointNamespace ( | ||
namespace_id BIGINT NOT NULL | ||
REFERENCES access.namespace(id) | ||
ON DELETE CASCADE, | ||
endpoint_id BIGINT NOT NULL | ||
REFERENCES access.endpoint(id) | ||
ON DELETE CASCADE | ||
); | ||
|
||
CREATE UNIQUE INDEX endpointNamespace_eid_nid_uq | ||
ON access.endpointNamespace(endpoint_id, namespace_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- | ||
-- Copyright (c) 2025 SUSE LLC | ||
-- | ||
-- This software is licensed to you under the GNU General Public License, | ||
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
-- along with this software; if not, see | ||
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
-- | ||
|
||
CREATE TABLE access.namespace ( | ||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | ||
namespace VARCHAR NOT NULL, | ||
access_mode CHAR(1) NOT NULL | ||
CHECK (access_mode IN ('R', 'W')), | ||
description TEXT | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- | ||
-- Copyright (c) 2025 SUSE LLC | ||
-- | ||
-- This software is licensed to you under the GNU General Public License, | ||
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
-- along with this software; if not, see | ||
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
-- | ||
|
||
CREATE TABLE access.userNamespace ( | ||
user_id NUMERIC NOT NULL | ||
REFERENCES public.web_contact(id) | ||
ON DELETE CASCADE, | ||
namespace_id BIGINT NOT NULL | ||
REFERENCES access.namespace(id) | ||
ON DELETE CASCADE | ||
); | ||
|
||
CREATE UNIQUE INDEX userNamespace_uid_nid_uq | ||
ON access.userNamespace(user_id, namespace_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- | ||
-- Copyright (c) 2025 SUSE LLC | ||
-- | ||
-- This software is licensed to you under the GNU General Public License, | ||
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
-- along with this software; if not, see | ||
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
-- | ||
|
||
CREATE VIEW access.endpointCatalog AS | ||
SELECT n.namespace, n.access_mode, e.endpoint, e.http_method, e.scope | ||
FROM access.endpointNamespace en, access.endpoint e, access.namespace n | ||
WHERE en.namespace_id = n.id AND en.endpoint_id = e.id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- | ||
-- Copyright (c) 2025 SUSE LLC | ||
-- | ||
-- This software is licensed to you under the GNU General Public License, | ||
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
-- along with this software; if not, see | ||
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
-- | ||
|
||
CREATE VIEW access.userAccessTable AS | ||
SELECT user_id, namespace, STRING_AGG(access_mode, '') AS access_mode | ||
FROM access.userNamespace un | ||
JOIN access.namespace n ON un.namespace_id = n.id | ||
GROUP BY user_id, namespace; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright (c) 2025 SUSE LLC | ||
# | ||
# This software is licensed to you under the GNU General Public License, | ||
# version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
# along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
# | ||
|
||
COMMON := ../../common/schemas | ||
|
||
common : | ||
@rm -rf common | ||
@mkdir -p common | ||
@cp -p -r $(COMMON)/* common | ||
|
||
clean : | ||
@rm -rf common | ||
|
||
.PHONY : common clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
schema/spacewalk/upgrade/susemanager-schema-5.1.3-to-susemanager-schema-5.1.4/200-rbac.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
-- | ||
-- Copyright (c) 2025 SUSE LLC | ||
-- | ||
-- This software is licensed to you under the GNU General Public License, | ||
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
-- along with this software; if not, see | ||
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
-- | ||
|
||
CREATE SCHEMA IF NOT EXISTS access; | ||
COMMENT ON SCHEMA access IS 'Contains the entities for RBAC'; | ||
|
||
CREATE TABLE IF NOT EXISTS access.endpoint ( | ||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | ||
class_method VARCHAR NOT NULL, | ||
endpoint VARCHAR NOT NULL, | ||
http_method VARCHAR NOT NULL, | ||
scope CHAR(1) NOT NULL | ||
CHECK (scope in ('A', 'W')), | ||
authorized BOOLEAN NOT NULL DEFAULT true, | ||
created TIMESTAMPTZ NOT NULL DEFAULT (current_timestamp), | ||
modified TIMESTAMPTZ NOT NULL DEFAULT (current_timestamp) | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS endpoint_endpoint_http_method_uq | ||
ON access.endpoint(endpoint, http_method); | ||
|
||
CREATE TABLE IF NOT EXISTS access.namespace ( | ||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | ||
namespace VARCHAR NOT NULL, | ||
access_mode CHAR(1) NOT NULL | ||
CHECK (access_mode IN ('R', 'W')), | ||
description TEXT | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS access.endpointNamespace ( | ||
namespace_id BIGINT NOT NULL | ||
REFERENCES access.namespace(id) | ||
ON DELETE CASCADE, | ||
endpoint_id BIGINT NOT NULL | ||
REFERENCES access.endpoint(id) | ||
ON DELETE CASCADE | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS endpointNamespace_eid_nid_uq | ||
ON access.endpointNamespace(endpoint_id, namespace_id); | ||
|
||
CREATE TABLE IF NOT EXISTS access.userNamespace ( | ||
user_id NUMERIC NOT NULL | ||
REFERENCES public.web_contact(id) | ||
ON DELETE CASCADE, | ||
namespace_id BIGINT NOT NULL | ||
REFERENCES access.namespace(id) | ||
ON DELETE CASCADE | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS userNamespace_uid_nid_uq | ||
ON access.userNamespace(user_id, namespace_id); | ||
|
||
|
||
CREATE OR REPLACE VIEW access.endpointCatalog AS | ||
SELECT n.namespace, n.access_mode, e.endpoint, e.http_method, e.scope | ||
FROM access.endpointNamespace en, access.endpoint e, access.namespace n | ||
WHERE en.namespace_id = n.id AND en.endpoint_id = e.id; | ||
|
||
|
||
CREATE OR REPLACE VIEW access.userAccessTable AS | ||
SELECT user_id, namespace, STRING_AGG(access_mode, '') AS access_mode | ||
FROM access.userNamespace un | ||
JOIN access.namespace n ON un.namespace_id = n.id | ||
GROUP BY user_id, namespace; | ||
|