hazo_auth 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +230 -0
- package/SETUP_CHECKLIST.md +202 -0
- package/bin/hazo_auth.mjs +35 -0
- package/cli-src/assets/images/forgot_password_default.jpg +0 -0
- package/cli-src/assets/images/login_default.jpg +0 -0
- package/cli-src/assets/images/register_default.jpg +0 -0
- package/cli-src/assets/images/reset_password_default.jpg +0 -0
- package/cli-src/assets/images/verify_email_default.jpg +0 -0
- package/cli-src/cli/generate.ts +276 -0
- package/cli-src/cli/index.ts +207 -0
- package/cli-src/cli/init.ts +254 -0
- package/cli-src/cli/init_users.ts +376 -0
- package/cli-src/cli/validate.ts +581 -0
- package/cli-src/lib/already_logged_in_config.server.ts +46 -0
- package/cli-src/lib/app_logger.ts +24 -0
- package/cli-src/lib/auth/auth_cache.ts +220 -0
- package/cli-src/lib/auth/auth_rate_limiter.ts +121 -0
- package/cli-src/lib/auth/auth_types.ts +110 -0
- package/cli-src/lib/auth/auth_utils.server.ts +196 -0
- package/cli-src/lib/auth/hazo_get_auth.server.ts +512 -0
- package/cli-src/lib/auth/index.ts +23 -0
- package/cli-src/lib/auth/nextauth_config.ts +227 -0
- package/cli-src/lib/auth/scope_cache.ts +233 -0
- package/cli-src/lib/auth/server_auth.ts +88 -0
- package/cli-src/lib/auth/session_token_validator.edge.ts +91 -0
- package/cli-src/lib/auth_utility_config.server.ts +136 -0
- package/cli-src/lib/config/config_loader.server.ts +164 -0
- package/cli-src/lib/config/default_config.ts +199 -0
- package/cli-src/lib/email_verification_config.server.ts +63 -0
- package/cli-src/lib/file_types_config.server.ts +25 -0
- package/cli-src/lib/forgot_password_config.server.ts +63 -0
- package/cli-src/lib/hazo_connect_instance.server.ts +101 -0
- package/cli-src/lib/hazo_connect_setup.server.ts +194 -0
- package/cli-src/lib/hazo_connect_setup.ts +54 -0
- package/cli-src/lib/index.ts +46 -0
- package/cli-src/lib/login_config.server.ts +106 -0
- package/cli-src/lib/messages_config.server.ts +45 -0
- package/cli-src/lib/migrations/apply_migration.ts +105 -0
- package/cli-src/lib/my_settings_config.server.ts +135 -0
- package/cli-src/lib/oauth_config.server.ts +87 -0
- package/cli-src/lib/password_requirements_config.server.ts +40 -0
- package/cli-src/lib/profile_pic_menu_config.server.ts +138 -0
- package/cli-src/lib/profile_picture_config.server.ts +56 -0
- package/cli-src/lib/register_config.server.ts +101 -0
- package/cli-src/lib/reset_password_config.server.ts +103 -0
- package/cli-src/lib/scope_hierarchy_config.server.ts +151 -0
- package/cli-src/lib/services/email_service.ts +587 -0
- package/cli-src/lib/services/email_verification_service.ts +270 -0
- package/cli-src/lib/services/index.ts +16 -0
- package/cli-src/lib/services/login_service.ts +150 -0
- package/cli-src/lib/services/oauth_service.ts +494 -0
- package/cli-src/lib/services/password_change_service.ts +154 -0
- package/cli-src/lib/services/password_reset_service.ts +418 -0
- package/cli-src/lib/services/profile_picture_remove_service.ts +120 -0
- package/cli-src/lib/services/profile_picture_service.ts +451 -0
- package/cli-src/lib/services/profile_picture_source_mapper.ts +62 -0
- package/cli-src/lib/services/registration_service.ts +185 -0
- package/cli-src/lib/services/scope_labels_service.ts +348 -0
- package/cli-src/lib/services/scope_service.ts +778 -0
- package/cli-src/lib/services/session_token_service.ts +177 -0
- package/cli-src/lib/services/token_service.ts +240 -0
- package/cli-src/lib/services/user_profiles_cache.ts +189 -0
- package/cli-src/lib/services/user_profiles_service.ts +264 -0
- package/cli-src/lib/services/user_scope_service.ts +554 -0
- package/cli-src/lib/services/user_update_service.ts +141 -0
- package/cli-src/lib/ui_shell_config.server.ts +73 -0
- package/cli-src/lib/ui_sizes_config.server.ts +37 -0
- package/cli-src/lib/user_fields_config.server.ts +31 -0
- package/cli-src/lib/user_management_config.server.ts +39 -0
- package/cli-src/lib/user_profiles_config.server.ts +55 -0
- package/cli-src/lib/utils/api_route_helpers.ts +60 -0
- package/cli-src/lib/utils/error_sanitizer.ts +75 -0
- package/cli-src/lib/utils/password_validator.ts +65 -0
- package/cli-src/lib/utils.ts +11 -0
- package/cli-src/server/logging/logger_service.ts +56 -0
- package/dist/app/api/hazo_auth/forgot_password/route.d.ts.map +1 -1
- package/dist/app/api/hazo_auth/forgot_password/route.js +15 -0
- package/dist/app/api/hazo_auth/logout/route.d.ts.map +1 -1
- package/dist/app/api/hazo_auth/logout/route.js +31 -0
- package/dist/app/api/hazo_auth/me/route.d.ts.map +1 -1
- package/dist/app/api/hazo_auth/me/route.js +10 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli/init_users.d.ts +17 -0
- package/dist/cli/init_users.d.ts.map +1 -0
- package/dist/cli/init_users.js +307 -0
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts +2 -0
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +8 -0
- package/dist/components/layouts/forgot_password/index.d.ts +7 -1
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +7 -2
- package/dist/components/layouts/login/index.d.ts +13 -1
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +11 -2
- package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts +17 -0
- package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/connected_accounts_section.js +17 -0
- package/dist/components/layouts/my_settings/components/set_password_section.d.ts +26 -0
- package/dist/components/layouts/my_settings/components/set_password_section.d.ts.map +1 -0
- package/dist/components/layouts/my_settings/components/set_password_section.js +127 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +3 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +9 -0
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +4 -2
- package/dist/components/layouts/shared/components/google_icon.d.ts +12 -0
- package/dist/components/layouts/shared/components/google_icon.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/google_icon.js +9 -0
- package/dist/components/layouts/shared/components/google_sign_in_button.d.ts +21 -0
- package/dist/components/layouts/shared/components/google_sign_in_button.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/google_sign_in_button.js +50 -0
- package/dist/components/layouts/shared/components/oauth_divider.d.ts +13 -0
- package/dist/components/layouts/shared/components/oauth_divider.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/oauth_divider.js +13 -0
- package/dist/components/layouts/shared/config/layout_customization.d.ts +2 -7
- package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +3 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.js +4 -0
- package/dist/components/layouts/shared/index.d.ts +5 -0
- package/dist/components/layouts/shared/index.d.ts.map +1 -1
- package/dist/components/layouts/shared/index.js +3 -0
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/lib/auth/nextauth_config.d.ts +34 -0
- package/dist/lib/auth/nextauth_config.d.ts.map +1 -0
- package/dist/lib/auth/nextauth_config.js +171 -0
- package/dist/lib/config/default_config.d.ts +24 -0
- package/dist/lib/config/default_config.d.ts.map +1 -1
- package/dist/lib/config/default_config.js +14 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/login_config.server.d.ts +3 -0
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +4 -0
- package/dist/lib/oauth_config.server.d.ts +29 -0
- package/dist/lib/oauth_config.server.d.ts.map +1 -0
- package/dist/lib/oauth_config.server.js +40 -0
- package/dist/lib/services/login_service.d.ts.map +1 -1
- package/dist/lib/services/login_service.js +16 -1
- package/dist/lib/services/oauth_service.d.ts +88 -0
- package/dist/lib/services/oauth_service.d.ts.map +1 -0
- package/dist/lib/services/oauth_service.js +376 -0
- package/dist/lib/services/password_reset_service.d.ts +2 -0
- package/dist/lib/services/password_reset_service.d.ts.map +1 -1
- package/dist/lib/services/password_reset_service.js +10 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +1 -0
- package/dist/lib/utils/password_validator.d.ts +19 -0
- package/dist/lib/utils/password_validator.d.ts.map +1 -0
- package/dist/lib/utils/password_validator.js +36 -0
- package/dist/server_pages/login.d.ts.map +1 -1
- package/dist/server_pages/login.js +6 -1
- package/dist/server_pages/login_client_wrapper.d.ts +5 -2
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/login_client_wrapper.js +2 -2
- package/package.json +6 -2
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// file_description: server-only helper to read HRBAC scope hierarchy configuration from hazo_auth_config.ini
|
|
2
|
+
// section: imports
|
|
3
|
+
import {
|
|
4
|
+
get_config_value,
|
|
5
|
+
get_config_number,
|
|
6
|
+
get_config_boolean,
|
|
7
|
+
get_config_array,
|
|
8
|
+
} from "./config/config_loader.server";
|
|
9
|
+
import type { ScopeLevel } from "./services/scope_service";
|
|
10
|
+
import { SCOPE_LEVELS } from "./services/scope_service";
|
|
11
|
+
|
|
12
|
+
// section: types
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Scope hierarchy configuration options for HRBAC
|
|
16
|
+
*/
|
|
17
|
+
export type ScopeHierarchyConfig = {
|
|
18
|
+
/** Whether HRBAC is enabled (default: false) */
|
|
19
|
+
enable_hrbac: boolean;
|
|
20
|
+
/** Default organization for single-tenant apps (optional) */
|
|
21
|
+
default_org: string;
|
|
22
|
+
/** Cache TTL in minutes for scope lookups (default: 15) */
|
|
23
|
+
scope_cache_ttl_minutes: number;
|
|
24
|
+
/** Maximum entries in scope cache (default: 5000) */
|
|
25
|
+
scope_cache_max_entries: number;
|
|
26
|
+
/** Which scope levels are active/enabled */
|
|
27
|
+
active_levels: ScopeLevel[];
|
|
28
|
+
/** Default labels for each scope level */
|
|
29
|
+
default_labels: Record<ScopeLevel, string>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// section: constants
|
|
33
|
+
|
|
34
|
+
const SECTION_NAME = "hazo_auth__scope_hierarchy";
|
|
35
|
+
|
|
36
|
+
const DEFAULT_LABELS: Record<ScopeLevel, string> = {
|
|
37
|
+
hazo_scopes_l1: "Level 1",
|
|
38
|
+
hazo_scopes_l2: "Level 2",
|
|
39
|
+
hazo_scopes_l3: "Level 3",
|
|
40
|
+
hazo_scopes_l4: "Level 4",
|
|
41
|
+
hazo_scopes_l5: "Level 5",
|
|
42
|
+
hazo_scopes_l6: "Level 6",
|
|
43
|
+
hazo_scopes_l7: "Level 7",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// section: helpers
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parses the active_levels config value into an array of ScopeLevel
|
|
50
|
+
* If not configured, returns all levels
|
|
51
|
+
*/
|
|
52
|
+
function parse_active_levels(config_value: string): ScopeLevel[] {
|
|
53
|
+
if (!config_value || config_value.trim().length === 0) {
|
|
54
|
+
return [...SCOPE_LEVELS]; // All levels active by default
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const levels = config_value.split(",").map((s) => s.trim());
|
|
58
|
+
const valid_levels: ScopeLevel[] = [];
|
|
59
|
+
|
|
60
|
+
for (const level of levels) {
|
|
61
|
+
if (SCOPE_LEVELS.includes(level as ScopeLevel)) {
|
|
62
|
+
valid_levels.push(level as ScopeLevel);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return valid_levels.length > 0 ? valid_levels : [...SCOPE_LEVELS];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Reads default labels from config, falling back to defaults
|
|
71
|
+
*/
|
|
72
|
+
function get_default_labels(): Record<ScopeLevel, string> {
|
|
73
|
+
const labels = { ...DEFAULT_LABELS };
|
|
74
|
+
|
|
75
|
+
for (let i = 1; i <= 7; i++) {
|
|
76
|
+
const level = `hazo_scopes_l${i}` as ScopeLevel;
|
|
77
|
+
const config_key = `default_label_l${i}`;
|
|
78
|
+
const config_value = get_config_value(SECTION_NAME, config_key, "");
|
|
79
|
+
|
|
80
|
+
if (config_value && config_value.trim().length > 0) {
|
|
81
|
+
labels[level] = config_value.trim();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return labels;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Reads HRBAC scope hierarchy configuration from hazo_auth_config.ini file
|
|
90
|
+
* Falls back to defaults if config file is not found or section is missing
|
|
91
|
+
* @returns Scope hierarchy configuration options
|
|
92
|
+
*/
|
|
93
|
+
export function get_scope_hierarchy_config(): ScopeHierarchyConfig {
|
|
94
|
+
// Core HRBAC enablement
|
|
95
|
+
const enable_hrbac = get_config_boolean(SECTION_NAME, "enable_hrbac", false);
|
|
96
|
+
|
|
97
|
+
// Default organization for single-tenant apps
|
|
98
|
+
const default_org = get_config_value(SECTION_NAME, "default_org", "");
|
|
99
|
+
|
|
100
|
+
// Cache settings
|
|
101
|
+
const scope_cache_ttl_minutes = get_config_number(
|
|
102
|
+
SECTION_NAME,
|
|
103
|
+
"scope_cache_ttl_minutes",
|
|
104
|
+
15,
|
|
105
|
+
);
|
|
106
|
+
const scope_cache_max_entries = get_config_number(
|
|
107
|
+
SECTION_NAME,
|
|
108
|
+
"scope_cache_max_entries",
|
|
109
|
+
5000,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Active levels
|
|
113
|
+
const active_levels_str = get_config_value(SECTION_NAME, "active_levels", "");
|
|
114
|
+
const active_levels = parse_active_levels(active_levels_str);
|
|
115
|
+
|
|
116
|
+
// Default labels
|
|
117
|
+
const default_labels = get_default_labels();
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
enable_hrbac,
|
|
121
|
+
default_org,
|
|
122
|
+
scope_cache_ttl_minutes,
|
|
123
|
+
scope_cache_max_entries,
|
|
124
|
+
active_levels,
|
|
125
|
+
default_labels,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Checks if HRBAC is enabled in the configuration
|
|
131
|
+
* Convenience function for quick checks
|
|
132
|
+
*/
|
|
133
|
+
export function is_hrbac_enabled(): boolean {
|
|
134
|
+
return get_config_boolean(SECTION_NAME, "enable_hrbac", false);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Gets the default organization from config
|
|
139
|
+
* Returns empty string if not configured (multi-tenant mode)
|
|
140
|
+
*/
|
|
141
|
+
export function get_default_org(): string {
|
|
142
|
+
return get_config_value(SECTION_NAME, "default_org", "");
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Gets the default label for a scope level
|
|
147
|
+
*/
|
|
148
|
+
export function get_default_label(level: ScopeLevel): string {
|
|
149
|
+
const config_key = `default_label_l${level.charAt(level.length - 1)}`;
|
|
150
|
+
return get_config_value(SECTION_NAME, config_key, DEFAULT_LABELS[level]);
|
|
151
|
+
}
|