Skip to content

Latest commit

 

History

History
157 lines (155 loc) · 58 KB

functions.md

File metadata and controls

157 lines (155 loc) · 58 KB

Features map

Categorized list of database functions with permissions and remarks, if applicable

Group Feature Function Permissions Remarks
Database versioning Marks version update start start_version_update(_version text, _title text, _description text default null)
Database versioning Marks version update end stop_version_update(_version text) Just to see how long itthe update took and if it was successful
Helper functions
Generate random string helpers.random_string(len integer DEFAULT 36) The function is based on MD5 and just cuts the generated string to desired length
Get code from title in plain Latin helpers.get_code(_title text, _separator text default '-') All whitespaces and special characters are replaced with _separator character (defaults to -) and whole ext is unaccented with ext.unaccent(text) function
Get ltree parent X level above helpers.ltree_parent(path ext.ltree, levels integer DEFAULT 1)
Automated code generation from title using trigger helpers.trg_generate_code_from_title() Uses helpers.get_code() and expects title column in the table
Authorization related functions
unsecure.create_auth_event(_created_by text, _user_id bigint, _event_type_code text,
auth.create_auth_event(_created_by text, _user_id bigint, _event_type_code text,
unsecure.clear_permission_cache(_deleted_by text, _tenant_id int, _target_user_id bigint)
unsecure.recalculate_user_groups(_created_by text,
unsecure.recalculate_user_permissions(_created_by text, _tenant_id int, _target_user_id bigint)
auth.has_permissions(_tenant_id int, _target_user_id bigint, _perm_codes text[],
auth.has_permission(_tenant_id int, _target_user_id bigint, _perm_code text,
auth.throw_no_access(_tenant_id int, _username text)
auth.throw_no_permission(_tenant_id int, _user_id bigint, _perm_codes text[])
auth.throw_no_permission(_tenant_id int, _user_id bigint, _perm_code text)
auth.ensure_groups_and_permissions(_created_by text, _user_id bigint, _target_user_id bigint,
Identity provider management
auth.validate_provider_is_active(_provider_code text)
auth.create_provider(_created_by text, _user_id bigint, _provider_code text, _provider_name text,
auth.update_provider(_modified_by text, _user_id bigint, _provider_id int, _provider_code text,
auth.delete_provider(_deleted_by text, _user_id bigint, _provider_code text)
auth.get_provider_users(_requested_by text, _user_id bigint, _provider_code text)
auth.enable_provider(_modified_by text, _user_id bigint, _provider_code text)
auth.disable_provider(_modified_by text, _user_id bigint, _provider_code text)
Tenant management
unsecure.create_primary_tenant()
unsecure.delete_user_by_username_as_system(_username text)
unsecure.expire_tokens(_created_by text)
auth.get_tenants(_user_id bigint)
auth.get_tenant_by_id(_tenant_id int)
auth.get_tenant_users(_requested_by text, _user_id bigint, _tenant_id int)
auth.get_tenant_groups(_requested_by text, _user_id bigint, _tenant_id int)
auth.get_tenant_members(_requested_by text, _user_id bigint, _tenant_id int)
auth.get_tenant_permissions(_tenant_id int, _user_id bigint)
public.assign_tenant_owner(_created_by text, _user_id bigint, _tenant_id int, _target_user_id bigint)
public.create_tenant(_created_by text, _user_id bigint, _title text, _code text default null,
REMOVE
TO REMOVE unsecure.add_user_group_member(_created_by text, _user_id bigint, _tenant_id int, _user_group_id int,
TO REMOVE unsecure.add_user_to_group_as_system(_user_name text, _group_title text, _tenant_id int default null)
Permission management
unsecure.update_permission_full_title(_perm_path ext.ltree)
unsecure.update_permission_full_code(_perm_path ext.ltree)
unsecure.create_permission_by_path_as_system(_title text
unsecure.assign_permission(_created_by text, _user_id bigint, _tenant_id int,
unsecure.unassign_permission(_deleted_by text, _user_id bigint, _tenant_id int,
unsecure.set_permission_as_assignable(_modified_by text, _user_id bigint,
unsecure.assign_permission_as_system(_tenant_id int, _user_group_id int, _target_user_id bigint,
unsecure.create_perm_set(
unsecure.create_perm_set_as_system(
unsecure.update_perm_set(
unsecure.add_perm_set_permissions(_created_by text, _user_id bigint, _tenant_id int,
unsecure.delete_perm_set_permissions(_deleted_by text, _user_id bigint, _tenant_id int,
unsecure.update_last_used_provider(_target_user_id bigint, _provider_code text)
auth.set_permission_as_assignable(_modified_by text, _user_id bigint,
auth.assign_permission(_created_by text, _user_id bigint, _tenant_id int, _user_group_id int,
auth.unassign_permission(_deleted_by text, _user_id bigint, _tenant_id int, _assignment_id int)
auth.create_permission_by_path(_created_by text, _user_id int,
auth.create_permission_by_code(_created_by text, _user_id int, _title text,
auth.create_perm_set(
auth.update_perm_set(
auth.add_perm_set_permissions(_created_by text, _user_id bigint, _tenant_id int, _perm_set_id int,
auth.delete_perm_set_permissions(_created_by text, _user_id bigint, _tenant_id int, _perm_set_id int,
User management
unsecure.create_system_user()
unsecure.create_user_info(_created_by text, _user_id bigint, _username text, _email text,
unsecure.create_user_identity(_created_by text, _user_id bigint, _target_user_id bigint,
unsecure.update_user_password(_modified_by text, _user_id bigint, _target_user_id bigint,
unsecure.add_user_to_default_groups(_created_by text, _user_id bigint, _target_user_id bigint,
auth.enable_user(_modified_by text, _user_id bigint, _target_user_id bigint)
auth.disable_user(_modified_by text, _user_id bigint, _target_user_id bigint)
auth.unlock_user(_modified_by text, _user_id bigint, _target_user_id bigint)
auth.lock_user(_modified_by text, _user_id bigint, _target_user_id bigint)
auth.enable_user_identity(_modified_by text, _user_id bigint, _target_user_id bigint,
auth.disable_user_identity(_modified_by text, _user_id bigint, _target_user_id bigint,
auth.update_user_password(_modified_by text, _user_id bigint, _target_user_id bigint,
auth.add_user_to_default_groups(_created_by text, _user_id bigint, _target_user_id bigint,
auth.get_user_by_id(_user_id bigint)
auth.get_user_identity(_user_id bigint, _target_user_id bigint, _provider_code text)
auth.get_user_identity_by_email(_user_id bigint, _email text, _provider_code text)
auth.get_user_by_email_for_authentication(_user_id int, _email text)
auth.ensure_user_from_provider(_created_by text, _user_id bigint, _provider_code text,
auth.update_user_data(_modified_by text, _user_id bigint, _target_user_id bigint, _provider text,
auth.get_user_random_code()
User group management
unsecure.create_user_group(_created_by text, _user_id bigint, _title text
unsecure.create_user_group_as_system(_tenant_id int, _title text
unsecure.get_user_group_members(_requested_by text, _user_id bigint, _tenant_id int, _user_group_id int)
create user group auth.create_user_group(_created_by text, _user_id bigint, _title text, _tenant_id int,
update user group auth.update_user_group(_modified_by text, _user_id bigint, _tenant_id int, _ug_id int, _title text,
enable user group auth.enable_user_group(_modified_by text, _user_id bigint, _tenant_id int, _user_group_id int)
disable user group auth.disable_user_group(_modified_by text, _user_id bigint, _tenant_id int, _user_group_id int)
lock user group auth.lock_user_group(_modified_by text, _user_id bigint, _tenant_id int, _user_group_id int)
unlock user group auth.unlock_user_group(_modified_by text, _user_id bigint, _tenant_id int, _user_group_id int)
delete user group auth.delete_user_group(_deleted_by text, _user_id bigint, _tenant_id int, _user_group_id int)
add user to user group auth.create_user_group_member(_created_by text, _user_id bigint, _tenant_id int, _user_group_id int,
remove user from user group auth.delete_user_group_member(_deleted_by text, _user_id bigint, _tenant_id int, _ug_id int,
get user group members auth.get_user_group_members(_requested_by text, _user_id bigint, _tenant_id int, _user_group_id int)
create user group mapping auth.create_user_group_mapping(_created_by text, _user_id bigint, _tenant_id int, _user_group_id int,
delete user group mapping auth.delete_user_group_mapping(_deleted_by text, _user_id bigint, _tenant_id int, _ug_mapping_id int)
create external user group auth.create_external_user_group(_created_by text, _user_id bigint, _title text, _tenant_id int,
auth.set_user_group_as_external(_modified_by text, _user_id bigint, _tenant_id int, _user_group_id int)
auth.set_user_group_as_hybrid(_modified_by text, _user_id bigint, _tenant_id int, _user_group_id int)
auth.register_user(_created_by text, _user_id int, _email text, _password_hash text,
Public general functions
add_journal_msg_jsonb(_created_by text, _tenant_id int, _user_id bigint, _msg text,
add_journal_msg(_created_by text, _tenant_id int, _user_id bigint, _msg text,
get_journal_msgs(_tenant_id int, _user_id int, _from timestamptz, _to timestamptz)
get_journal_payload(_tenant_id int, _user_id int, _journal_id bigint)
public.calculate_roles_and_permissions(_user_id bigint, _provider_groups text[], _provider_roles text[])
load_initial_data()
Token management functions
auth.create_token(_created_by text, _user_id bigint,
auth.validate_token(_modified_by text, _user_id bigint,
auth.set_token_as_used(_modified_by text, _user_id bigint, _token_id bigint,
Authorized functions
Authentication Ensure user from external identity provider
Authentication Ensure user's groups and permissions Also based on groups and roles coming from identity provider
Authentication Ensure user's groups and permissions Also based on groups and roles coming from identity provider
Error raising functions
Error handling Throws 52101 error to stop processing of the function error.raise_52101(_username text)
Error handling Throws 52102 error to stop processing of the function error.raise_52102(_normalized_email text)
Error handling Throws 52103 error to stop processing of the function error.raise_52103(_user_id bigint, _email text default null)
Error handling Throws 52104 error to stop processing of the function error.raise_52104(_user_id bigint)
Error handling Throws 52105 error to stop processing of the function error.raise_52105(_user_id bigint)
Error handling Throws 52106 error to stop processing of the function error.raise_52106(_email text)
Error handling Throws 52107 error to stop processing of the function error.raise_52107(_provider_code text)
Error handling Throws 52108 error to stop processing of the function error.raise_52108(_tenant_id text, _username text)
Error handling Throws 52109 error to stop processing of the function error.raise_52109(_user_id bigint, _tenant_id int, _perm_codes text[])
Error handling Throws 52110 error to stop processing of the function error.raise_52110(_user_id bigint, _provider_code text)
Error handling Throws 52111 error to stop processing of the function error.raise_52111(_user_id bigint, _provider_code text)
Error handling Throws 52112 error to stop processing of the function error.raise_52112(_user_id bigint)
Error handling Throws 52171 error to stop processing of the function error.raise_52171(_user_group_id int)
Error handling Throws 52172 error to stop processing of the function error.raise_52172(_user_group_id int)
Error handling Throws 52173 error to stop processing of the function error.raise_52173(_user_group_id int)
Error handling Throws 52174 error to stop processing of the function error.raise_52174()
Error handling Throws 52175 error to stop processing of the function error.raise_52175(_perm_set_code text)
Error handling Throws 52176 error to stop processing of the function error.raise_52176(_perm_set_code text)
Error handling Throws 52177 error to stop processing of the function error.raise_52177(_perm_set_id int, _tenant_id int)
Error handling Throws 52178 error to stop processing of the function error.raise_52178()
Error handling Throws 52271 error to stop processing of the function error.raise_52271(_user_group_id int)
Error handling Throws 52272 error to stop processing of the function error.raise_52272()
Error handling Throws 52273 error to stop processing of the function error.raise_52273()
Error handling Throws 52274 error to stop processing of the function error.raise_52274()
Error handling Throws 52275 error to stop processing of the function error.raise_52275(_permission_full_code text)
Error handling Throws 52276 error to stop processing of the function error.raise_52276()
Error handling Throws 52277 error to stop processing of the function error.raise_52277()
Error handling Throws 52278 error to stop processing of the function error.raise_52278(_token_uid text)
Error handling Throws 52279 error to stop processing of the function error.raise_52279(_token_uid text)