hazo_auth 0.1.2 → 1.0.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/hazo_auth_config.example.ini +75 -0
- package/instrumentation.ts +1 -1
- package/next.config.mjs +1 -1
- package/package.json +4 -1
- package/src/app/api/{auth → hazo_auth/auth}/upload_profile_picture/route.ts +2 -2
- package/src/app/api/{auth → hazo_auth}/change_password/route.ts +23 -0
- package/src/app/api/hazo_auth/get_auth/route.ts +89 -0
- package/src/app/api/hazo_auth/invalidate_cache/route.ts +139 -0
- package/src/app/api/{auth → hazo_auth}/library_photos/route.ts +3 -0
- package/src/app/api/{auth → hazo_auth}/logout/route.ts +27 -0
- package/src/app/api/hazo_auth/upload_profile_picture/route.ts +268 -0
- package/src/app/api/hazo_auth/user_management/permissions/route.ts +367 -0
- package/src/app/api/hazo_auth/user_management/roles/route.ts +442 -0
- package/src/app/api/hazo_auth/user_management/users/roles/route.ts +367 -0
- package/src/app/api/hazo_auth/user_management/users/route.ts +239 -0
- package/src/app/api/{auth → hazo_auth}/validate_reset_token/route.ts +3 -0
- package/src/app/api/{auth → hazo_auth}/verify_email/route.ts +3 -0
- package/src/app/globals.css +1 -1
- package/src/app/hazo_auth/user_management/page.tsx +14 -0
- package/src/app/hazo_auth/user_management/user_management_page_client.tsx +16 -0
- package/src/app/hazo_connect/api/sqlite/data/route.ts +7 -1
- package/src/app/hazo_connect/api/sqlite/schema/route.ts +14 -4
- package/src/app/hazo_connect/api/sqlite/tables/route.ts +14 -4
- package/src/app/hazo_connect/sqlite_admin/sqlite-admin-client.tsx +40 -3
- package/src/app/layout.tsx +1 -1
- package/src/app/page.tsx +4 -4
- package/src/components/layouts/email_verification/hooks/use_email_verification.ts +4 -4
- package/src/components/layouts/email_verification/index.tsx +1 -1
- package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +1 -1
- package/src/components/layouts/login/hooks/use_login_form.ts +2 -2
- package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +1 -1
- package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +35 -6
- package/src/components/layouts/my_settings/hooks/use_my_settings.ts +5 -5
- package/src/components/layouts/my_settings/index.tsx +1 -1
- package/src/components/layouts/register/hooks/use_register_form.ts +1 -1
- package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +3 -3
- package/src/components/layouts/reset_password/index.tsx +2 -2
- package/src/components/layouts/shared/components/logout_button.tsx +1 -1
- package/src/components/layouts/shared/components/profile_pic_menu.tsx +321 -0
- package/src/components/layouts/shared/components/profile_pic_menu_wrapper.tsx +40 -0
- package/src/components/layouts/shared/components/sidebar_layout_wrapper.tsx +22 -72
- package/src/components/layouts/shared/components/unauthorized_guard.tsx +1 -1
- package/src/components/layouts/shared/hooks/use_auth_status.ts +1 -1
- package/src/components/layouts/shared/hooks/use_hazo_auth.ts +158 -0
- package/src/components/layouts/user_management/components/roles_matrix.tsx +607 -0
- package/src/components/layouts/user_management/index.tsx +1295 -0
- package/src/components/ui/alert-dialog.tsx +141 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/dropdown-menu.tsx +201 -0
- package/src/components/ui/table.tsx +120 -0
- package/src/lib/auth/auth_cache.ts +220 -0
- package/src/lib/auth/auth_rate_limiter.ts +121 -0
- package/src/lib/auth/auth_types.ts +65 -0
- package/src/lib/auth/hazo_get_auth.server.ts +333 -0
- package/src/lib/auth_utility_config.server.ts +136 -0
- package/src/lib/hazo_connect_setup.server.ts +2 -3
- package/src/lib/my_settings_config.server.ts +1 -1
- package/src/lib/profile_pic_menu_config.server.ts +138 -0
- package/src/lib/reset_password_config.server.ts +5 -5
- package/src/lib/services/email_service.ts +2 -2
- package/src/lib/services/profile_picture_remove_service.ts +1 -1
- package/src/lib/services/token_service.ts +2 -2
- package/src/lib/user_management_config.server.ts +40 -0
- package/src/lib/utils.ts +1 -1
- package/src/middleware.ts +15 -13
- package/src/server/types/express.d.ts +1 -0
- package/src/stories/project_overview.stories.tsx +1 -1
- package/tailwind.config.ts +1 -1
- /package/src/app/api/{auth → hazo_auth}/forgot_password/route.ts +0 -0
- /package/src/app/api/{auth → hazo_auth}/login/route.ts +0 -0
- /package/src/app/api/{auth → hazo_auth}/me/route.ts +0 -0
- /package/src/app/api/{auth → hazo_auth}/profile_picture/[filename]/route.ts +0 -0
- /package/src/app/api/{auth → hazo_auth}/register/route.ts +0 -0
- /package/src/app/api/{auth → hazo_auth}/remove_profile_picture/route.ts +0 -0
- /package/src/app/api/{auth → hazo_auth}/resend_verification/route.ts +0 -0
- /package/src/app/api/{auth → hazo_auth}/reset_password/route.ts +0 -0
- /package/src/app/api/{auth → hazo_auth}/update_user/route.ts +0 -0
- /package/src/app/{forgot_password → hazo_auth/forgot_password}/forgot_password_page_client.tsx +0 -0
- /package/src/app/{forgot_password → hazo_auth/forgot_password}/page.tsx +0 -0
- /package/src/app/{login → hazo_auth/login}/login_page_client.tsx +0 -0
- /package/src/app/{login → hazo_auth/login}/page.tsx +0 -0
- /package/src/app/{my_settings → hazo_auth/my_settings}/my_settings_page_client.tsx +0 -0
- /package/src/app/{my_settings → hazo_auth/my_settings}/page.tsx +0 -0
- /package/src/app/{register → hazo_auth/register}/page.tsx +0 -0
- /package/src/app/{register → hazo_auth/register}/register_page_client.tsx +0 -0
- /package/src/app/{reset_password → hazo_auth/reset_password}/page.tsx +0 -0
- /package/src/app/{reset_password → hazo_auth/reset_password}/reset_password_page_client.tsx +0 -0
- /package/src/app/{verify_email → hazo_auth/verify_email}/page.tsx +0 -0
- /package/src/app/{verify_email → hazo_auth/verify_email}/verify_email_page_client.tsx +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// file_description: server-only helper to read user management configuration from hazo_auth_config.ini
|
|
2
|
+
// section: imports
|
|
3
|
+
import { get_config_value, get_config_array } from "./config/config_loader.server";
|
|
4
|
+
import { read_config_section } from "./config/config_loader.server";
|
|
5
|
+
|
|
6
|
+
// section: types
|
|
7
|
+
export type UserManagementConfig = {
|
|
8
|
+
application_permission_list_defaults: string[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// section: helpers
|
|
12
|
+
/**
|
|
13
|
+
* Reads user management configuration from hazo_auth_config.ini file
|
|
14
|
+
* Falls back to defaults if hazo_auth_config.ini is not found or section is missing
|
|
15
|
+
* @returns User management configuration options
|
|
16
|
+
*/
|
|
17
|
+
export function get_user_management_config(): UserManagementConfig {
|
|
18
|
+
// Try to read from hazo_auth__user_management section first
|
|
19
|
+
const user_management_section = read_config_section("hazo_auth__user_management");
|
|
20
|
+
const permissions_section = read_config_section("permissions");
|
|
21
|
+
|
|
22
|
+
// Try application_permission_list_defaults from user_management section
|
|
23
|
+
let permission_list: string[] = [];
|
|
24
|
+
|
|
25
|
+
if (user_management_section?.application_permission_list_defaults) {
|
|
26
|
+
permission_list = get_config_array(
|
|
27
|
+
"hazo_auth__user_management",
|
|
28
|
+
"application_permission_list_defaults",
|
|
29
|
+
[]
|
|
30
|
+
);
|
|
31
|
+
} else if (permissions_section?.list) {
|
|
32
|
+
// Fallback to permissions section list key
|
|
33
|
+
permission_list = get_config_array("permissions", "list", []);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
application_permission_list_defaults: permission_list,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
package/src/lib/utils.ts
CHANGED
package/src/middleware.ts
CHANGED
|
@@ -35,18 +35,20 @@ export async function middleware(request: NextRequest) {
|
|
|
35
35
|
|
|
36
36
|
// Public routes that don't require authentication
|
|
37
37
|
const public_routes = [
|
|
38
|
-
"/login",
|
|
39
|
-
"/register",
|
|
40
|
-
"/forgot_password",
|
|
41
|
-
"/reset_password",
|
|
42
|
-
"/verify_email",
|
|
43
|
-
"/api/
|
|
44
|
-
"/api/
|
|
45
|
-
"/api/
|
|
46
|
-
"/api/
|
|
47
|
-
"/api/
|
|
48
|
-
"/api/
|
|
49
|
-
"/api/
|
|
38
|
+
"/hazo_auth/login",
|
|
39
|
+
"/hazo_auth/register",
|
|
40
|
+
"/hazo_auth/forgot_password",
|
|
41
|
+
"/hazo_auth/reset_password",
|
|
42
|
+
"/hazo_auth/verify_email",
|
|
43
|
+
"/api/hazo_auth/login",
|
|
44
|
+
"/api/hazo_auth/register",
|
|
45
|
+
"/api/hazo_auth/forgot_password",
|
|
46
|
+
"/api/hazo_auth/reset_password",
|
|
47
|
+
"/api/hazo_auth/verify_email",
|
|
48
|
+
"/api/hazo_auth/validate_reset_token",
|
|
49
|
+
"/api/hazo_auth/me", // Allow /api/hazo_auth/me to be public (returns authenticated: false if not logged in)
|
|
50
|
+
"/hazo_connect/api/sqlite", // SQLite Admin API routes (admin tool, should be accessible)
|
|
51
|
+
"/hazo_connect/sqlite_admin", // SQLite Admin UI page
|
|
50
52
|
];
|
|
51
53
|
|
|
52
54
|
// Check if route is public
|
|
@@ -65,7 +67,7 @@ export async function middleware(request: NextRequest) {
|
|
|
65
67
|
|
|
66
68
|
if (!has_cookies) {
|
|
67
69
|
// Redirect to login if no cookies (not authenticated)
|
|
68
|
-
const login_url = new URL("/login", request.url);
|
|
70
|
+
const login_url = new URL("/hazo_auth/login", request.url);
|
|
69
71
|
login_url.searchParams.set("redirect", pathname);
|
|
70
72
|
return NextResponse.redirect(login_url);
|
|
71
73
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// file_description: provide a high level story describing the purpose of the
|
|
1
|
+
// file_description: provide a high level story describing the purpose of the hazo_auth workspace
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
3
3
|
|
|
4
4
|
// section: story_configuration
|
package/tailwind.config.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/app/{forgot_password → hazo_auth/forgot_password}/forgot_password_page_client.tsx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|