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.
Files changed (89) hide show
  1. package/hazo_auth_config.example.ini +75 -0
  2. package/instrumentation.ts +1 -1
  3. package/next.config.mjs +1 -1
  4. package/package.json +4 -1
  5. package/src/app/api/{auth → hazo_auth/auth}/upload_profile_picture/route.ts +2 -2
  6. package/src/app/api/{auth → hazo_auth}/change_password/route.ts +23 -0
  7. package/src/app/api/hazo_auth/get_auth/route.ts +89 -0
  8. package/src/app/api/hazo_auth/invalidate_cache/route.ts +139 -0
  9. package/src/app/api/{auth → hazo_auth}/library_photos/route.ts +3 -0
  10. package/src/app/api/{auth → hazo_auth}/logout/route.ts +27 -0
  11. package/src/app/api/hazo_auth/upload_profile_picture/route.ts +268 -0
  12. package/src/app/api/hazo_auth/user_management/permissions/route.ts +367 -0
  13. package/src/app/api/hazo_auth/user_management/roles/route.ts +442 -0
  14. package/src/app/api/hazo_auth/user_management/users/roles/route.ts +367 -0
  15. package/src/app/api/hazo_auth/user_management/users/route.ts +239 -0
  16. package/src/app/api/{auth → hazo_auth}/validate_reset_token/route.ts +3 -0
  17. package/src/app/api/{auth → hazo_auth}/verify_email/route.ts +3 -0
  18. package/src/app/globals.css +1 -1
  19. package/src/app/hazo_auth/user_management/page.tsx +14 -0
  20. package/src/app/hazo_auth/user_management/user_management_page_client.tsx +16 -0
  21. package/src/app/hazo_connect/api/sqlite/data/route.ts +7 -1
  22. package/src/app/hazo_connect/api/sqlite/schema/route.ts +14 -4
  23. package/src/app/hazo_connect/api/sqlite/tables/route.ts +14 -4
  24. package/src/app/hazo_connect/sqlite_admin/sqlite-admin-client.tsx +40 -3
  25. package/src/app/layout.tsx +1 -1
  26. package/src/app/page.tsx +4 -4
  27. package/src/components/layouts/email_verification/hooks/use_email_verification.ts +4 -4
  28. package/src/components/layouts/email_verification/index.tsx +1 -1
  29. package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +1 -1
  30. package/src/components/layouts/login/hooks/use_login_form.ts +2 -2
  31. package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +1 -1
  32. package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +35 -6
  33. package/src/components/layouts/my_settings/hooks/use_my_settings.ts +5 -5
  34. package/src/components/layouts/my_settings/index.tsx +1 -1
  35. package/src/components/layouts/register/hooks/use_register_form.ts +1 -1
  36. package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +3 -3
  37. package/src/components/layouts/reset_password/index.tsx +2 -2
  38. package/src/components/layouts/shared/components/logout_button.tsx +1 -1
  39. package/src/components/layouts/shared/components/profile_pic_menu.tsx +321 -0
  40. package/src/components/layouts/shared/components/profile_pic_menu_wrapper.tsx +40 -0
  41. package/src/components/layouts/shared/components/sidebar_layout_wrapper.tsx +22 -72
  42. package/src/components/layouts/shared/components/unauthorized_guard.tsx +1 -1
  43. package/src/components/layouts/shared/hooks/use_auth_status.ts +1 -1
  44. package/src/components/layouts/shared/hooks/use_hazo_auth.ts +158 -0
  45. package/src/components/layouts/user_management/components/roles_matrix.tsx +607 -0
  46. package/src/components/layouts/user_management/index.tsx +1295 -0
  47. package/src/components/ui/alert-dialog.tsx +141 -0
  48. package/src/components/ui/checkbox.tsx +30 -0
  49. package/src/components/ui/dropdown-menu.tsx +201 -0
  50. package/src/components/ui/table.tsx +120 -0
  51. package/src/lib/auth/auth_cache.ts +220 -0
  52. package/src/lib/auth/auth_rate_limiter.ts +121 -0
  53. package/src/lib/auth/auth_types.ts +65 -0
  54. package/src/lib/auth/hazo_get_auth.server.ts +333 -0
  55. package/src/lib/auth_utility_config.server.ts +136 -0
  56. package/src/lib/hazo_connect_setup.server.ts +2 -3
  57. package/src/lib/my_settings_config.server.ts +1 -1
  58. package/src/lib/profile_pic_menu_config.server.ts +138 -0
  59. package/src/lib/reset_password_config.server.ts +5 -5
  60. package/src/lib/services/email_service.ts +2 -2
  61. package/src/lib/services/profile_picture_remove_service.ts +1 -1
  62. package/src/lib/services/token_service.ts +2 -2
  63. package/src/lib/user_management_config.server.ts +40 -0
  64. package/src/lib/utils.ts +1 -1
  65. package/src/middleware.ts +15 -13
  66. package/src/server/types/express.d.ts +1 -0
  67. package/src/stories/project_overview.stories.tsx +1 -1
  68. package/tailwind.config.ts +1 -1
  69. /package/src/app/api/{auth → hazo_auth}/forgot_password/route.ts +0 -0
  70. /package/src/app/api/{auth → hazo_auth}/login/route.ts +0 -0
  71. /package/src/app/api/{auth → hazo_auth}/me/route.ts +0 -0
  72. /package/src/app/api/{auth → hazo_auth}/profile_picture/[filename]/route.ts +0 -0
  73. /package/src/app/api/{auth → hazo_auth}/register/route.ts +0 -0
  74. /package/src/app/api/{auth → hazo_auth}/remove_profile_picture/route.ts +0 -0
  75. /package/src/app/api/{auth → hazo_auth}/resend_verification/route.ts +0 -0
  76. /package/src/app/api/{auth → hazo_auth}/reset_password/route.ts +0 -0
  77. /package/src/app/api/{auth → hazo_auth}/update_user/route.ts +0 -0
  78. /package/src/app/{forgot_password → hazo_auth/forgot_password}/forgot_password_page_client.tsx +0 -0
  79. /package/src/app/{forgot_password → hazo_auth/forgot_password}/page.tsx +0 -0
  80. /package/src/app/{login → hazo_auth/login}/login_page_client.tsx +0 -0
  81. /package/src/app/{login → hazo_auth/login}/page.tsx +0 -0
  82. /package/src/app/{my_settings → hazo_auth/my_settings}/my_settings_page_client.tsx +0 -0
  83. /package/src/app/{my_settings → hazo_auth/my_settings}/page.tsx +0 -0
  84. /package/src/app/{register → hazo_auth/register}/page.tsx +0 -0
  85. /package/src/app/{register → hazo_auth/register}/register_page_client.tsx +0 -0
  86. /package/src/app/{reset_password → hazo_auth/reset_password}/page.tsx +0 -0
  87. /package/src/app/{reset_password → hazo_auth/reset_password}/reset_password_page_client.tsx +0 -0
  88. /package/src/app/{verify_email → hazo_auth/verify_email}/page.tsx +0 -0
  89. /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
@@ -1,4 +1,4 @@
1
- // file_description: provide shared utility helpers for the ui_component project
1
+ // file_description: provide shared utility helpers for the hazo_auth project
2
2
  import { clsx, type ClassValue } from "clsx";
3
3
  import { twMerge } from "tailwind-merge";
4
4
 
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/auth/login",
44
- "/api/auth/register",
45
- "/api/auth/forgot_password",
46
- "/api/auth/reset_password",
47
- "/api/auth/verify_email",
48
- "/api/auth/validate_reset_token",
49
- "/api/auth/me", // Allow /api/auth/me to be public (returns authenticated: false if not logged in)
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
  }
@@ -13,3 +13,4 @@ export {};
13
13
 
14
14
 
15
15
 
16
+
@@ -1,4 +1,4 @@
1
- // file_description: provide a high level story describing the purpose of the ui_component workspace
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
@@ -1,4 +1,4 @@
1
- // file_description: configure tailwindcss for the ui_component project
1
+ // file_description: configure tailwindcss for the hazo_auth project
2
2
  import type { Config } from "tailwindcss";
3
3
 
4
4
  // section: tailwind_configuration
File without changes
File without changes
File without changes