aboutsummaryrefslogtreecommitdiffstats
path: root/notes
diff options
context:
space:
mode:
authorDavid M. Syzdek <syzdek@bindlebinaries.com>2019-05-09 14:21:09 -0800
committerDavid M. Syzdek <syzdek@bindlebinaries.com>2019-05-09 14:26:25 -0800
commit30531a3ca587cd079f7c1237bbddf624f67b9422 (patch)
treea4103c84ba09248d499e5be928c7d93d76aa7096 /notes
parentd6888eb15f88261a88950330d804cf0052df2609 (diff)
downloadscratchpad-30531a3ca587cd079f7c1237bbddf624f67b9422.tar.gz
scratchpad-30531a3ca587cd079f7c1237bbddf624f67b9422.tar.bz2
scratchpad-30531a3ca587cd079f7c1237bbddf624f67b9422.tar.xz
scratchpad-30531a3ca587cd079f7c1237bbddf624f67b9422.zip
refactoring datbase roles for radius
Diffstat (limited to 'notes')
-rw-r--r--notes/projects/radius/sql/ippool-database.sql13
-rw-r--r--notes/projects/radius/sql/ippool-schema.sql39
-rw-r--r--notes/projects/radius/sql/ippool.md5
-rw-r--r--notes/projects/radius/sql/radius-roles.sql46
4 files changed, 90 insertions, 13 deletions
diff --git a/notes/projects/radius/sql/ippool-database.sql b/notes/projects/radius/sql/ippool-database.sql
index 660e676..1a4f4de 100644
--- a/notes/projects/radius/sql/ippool-database.sql
+++ b/notes/projects/radius/sql/ippool-database.sql
@@ -13,19 +13,8 @@ SET client_min_messages TO WARNING;
13\set ON_ERROR_STOP on 13\set ON_ERROR_STOP on
14 14
15 15
16CREATE ROLE radius_ippool
17 WITH NOSUPERUSER
18 NOCREATEDB
19 NOCREATEROLE
20 NOINHERIT
21 NOLOGIN
22 NOREPLICATION
23 NOBYPASSRLS
24 ADMIN admin;
25
26
27CREATE DATABASE radius_ippool 16CREATE DATABASE radius_ippool
28 WITH OWNER = radius_ippool 17 WITH OWNER = radius
29 ENCODING = "UTF8" 18 ENCODING = "UTF8"
30 LC_COLLATE = "en_US.UTF-8" 19 LC_COLLATE = "en_US.UTF-8"
31 LC_CTYPE = "en_US.UTF-8"; 20 LC_CTYPE = "en_US.UTF-8";
diff --git a/notes/projects/radius/sql/ippool-schema.sql b/notes/projects/radius/sql/ippool-schema.sql
index f0b259d..b948e58 100644
--- a/notes/projects/radius/sql/ippool-schema.sql
+++ b/notes/projects/radius/sql/ippool-schema.sql
@@ -7,11 +7,42 @@
7 */ 7 */
8 8
9 9
10SET ROLE radius_ippool; 10SET ROLE radius;
11SET client_min_messages TO WARNING; 11SET client_min_messages TO WARNING;
12\set ON_ERROR_STOP on 12\set ON_ERROR_STOP on
13 13
14 14
15-- //////////////////
16-- // //
17-- // Privileges //
18-- // //
19-- //////////////////
20
21
22-- GRANT CONNECT
23-- ON DATABASE radius_ippool
24-- TO radius_user;
25
26
27GRANT USAGE
28 ON SCHEMA public
29 TO radius_user;
30
31
32ALTER DEFAULT PRIVILEGES
33 IN SCHEMA public
34 GRANT SELECT
35 ON TABLES
36 TO radius_user;
37
38
39ALTER DEFAULT PRIVILEGES
40 IN SCHEMA public
41 GRANT EXECUTE
42 ON FUNCTIONS
43 TO radius_admin;
44
45
15-- ////////////// 46-- //////////////
16-- // // 47-- // //
17-- // Tables // 48-- // Tables //
@@ -212,6 +243,7 @@ CREATE OR REPLACE FUNCTION ip_add_network
212) 243)
213 RETURNS INTEGER 244 RETURNS INTEGER
214 LANGUAGE plpgsql 245 LANGUAGE plpgsql
246 SECURITY DEFINER
215 AS $$ 247 AS $$
216DECLARE 248DECLARE
217 ipAddress INET; 249 ipAddress INET;
@@ -276,6 +308,7 @@ CREATE OR REPLACE FUNCTION ip_assign
276) 308)
277 RETURNS BOOLEAN 309 RETURNS BOOLEAN
278 LANGUAGE plpgsql 310 LANGUAGE plpgsql
311 SECURITY DEFINER
279 AS $$ 312 AS $$
280DECLARE 313DECLARE
281BEGIN 314BEGIN
@@ -416,6 +449,7 @@ CREATE OR REPLACE FUNCTION nas_add
416) 449)
417 RETURNS INTEGER 450 RETURNS INTEGER
418 LANGUAGE plpgsql 451 LANGUAGE plpgsql
452 SECURITY DEFINER
419 AS $$ 453 AS $$
420DECLARE 454DECLARE
421 nasRegionId INTEGER; 455 nasRegionId INTEGER;
@@ -492,6 +526,7 @@ CREATE OR REPLACE FUNCTION netblock_add
492) 526)
493 RETURNS INTEGER 527 RETURNS INTEGER
494 LANGUAGE plpgsql 528 LANGUAGE plpgsql
529 SECURITY DEFINER
495 AS $$ 530 AS $$
496DECLARE 531DECLARE
497 netRegionId INTEGER DEFAULT NULL; 532 netRegionId INTEGER DEFAULT NULL;
@@ -676,6 +711,7 @@ CREATE OR REPLACE FUNCTION pool_add
676) 711)
677 RETURNS INTEGER 712 RETURNS INTEGER
678 LANGUAGE plpgsql 713 LANGUAGE plpgsql
714 SECURITY DEFINER
679 AS $$ 715 AS $$
680DECLARE 716DECLARE
681 returnId INTEGER; 717 returnId INTEGER;
@@ -721,6 +757,7 @@ CREATE OR REPLACE FUNCTION region_add
721) 757)
722 RETURNS INTEGER 758 RETURNS INTEGER
723 LANGUAGE plpgsql 759 LANGUAGE plpgsql
760 SECURITY DEFINER
724 AS $$ 761 AS $$
725DECLARE 762DECLARE
726 returnId INTEGER; 763 returnId INTEGER;
diff --git a/notes/projects/radius/sql/ippool.md b/notes/projects/radius/sql/ippool.md
index 72633f5..d5c1223 100644
--- a/notes/projects/radius/sql/ippool.md
+++ b/notes/projects/radius/sql/ippool.md
@@ -17,11 +17,16 @@ Files
17 * ippool-schema.sql - Creates database schema (tables, indexes, etc) 17 * ippool-schema.sql - Creates database schema (tables, indexes, etc)
18 * ippool-demo.sql - Loads demo data 18 * ippool-demo.sql - Loads demo data
19 * ippool-queries.sql - Common or useful queries 19 * ippool-queries.sql - Common or useful queries
20 * radius-roles.sql - Common database roles for RADIUS
20 21
21 22
22Initializing New Database 23Initializing New Database
23------------------------- 24-------------------------
24 25
26 * Create base database roles for RADIUS, not not already created:
27
28 psql -h raddbtest.prv.acsalaska.net -f radius-roles.sql
29
25 * Create database and load schema: 30 * Create database and load schema:
26 31
27 psql -h raddbtest.prv.acsalaska.net -f ippool-database.sql 32 psql -h raddbtest.prv.acsalaska.net -f ippool-database.sql
diff --git a/notes/projects/radius/sql/radius-roles.sql b/notes/projects/radius/sql/radius-roles.sql
new file mode 100644
index 0000000..c609c6f
--- /dev/null
+++ b/notes/projects/radius/sql/radius-roles.sql
@@ -0,0 +1,46 @@
1/*
2 * IP Engineering RADIUS Servers
3 *
4 * radius-roles.sql - creates base radius roles
5 *
6 * Usage: psql -f radius-roles.sql
7 *
8 */
9
10
11SET ROLE wheel;
12SET client_min_messages TO WARNING;
13\set ON_ERROR_STOP on
14
15
16CREATE ROLE radius
17 WITH NOSUPERUSER
18 NOCREATEDB
19 NOCREATEROLE
20 NOINHERIT
21 NOLOGIN
22 NOREPLICATION
23 ADMIN wheel;
24
25
26CREATE ROLE radius_admin
27 WITH NOSUPERUSER
28 NOCREATEDB
29 NOCREATEROLE
30 INHERIT
31 NOLOGIN
32 NOREPLICATION;
33
34
35CREATE ROLE radius_user
36 WITH NOSUPERUSER
37 NOCREATEDB
38 NOCREATEROLE
39 INHERIT
40 NOLOGIN
41 NOREPLICATION
42 NOBYPASSRLS
43 ADMIN radius_admin;
44
45
46/* end of sql */