diff --git a/client/src/pages/Settings.jsx b/client/src/pages/Settings.jsx index a9526fd..d2da4f9 100644 --- a/client/src/pages/Settings.jsx +++ b/client/src/pages/Settings.jsx @@ -457,17 +457,465 @@ const SecuritySettings = ({ tenantConfig, onRefresh }) => { ); }; -const AuthenticationSettings = () => ( -
-
-

Authentication Settings

-

- Authentication provider configuration will be available here. -

+const AuthenticationSettings = ({ tenantConfig }) => { + const [authConfig, setAuthConfig] = useState(null); + const [loading, setLoading] = useState(true); + const [saving, setSaving] = useState(false); + const [editing, setEditing] = useState(false); + + useEffect(() => { + fetchAuthConfig(); + }, []); + + const fetchAuthConfig = async () => { + try { + const response = await api.get('/tenant/auth'); + setAuthConfig(response.data.data); + } catch (error) { + console.error('Failed to fetch auth config:', error); + toast.error('Failed to load authentication settings'); + } finally { + setLoading(false); + } + }; + + const saveAuthConfig = async (newConfig) => { + setSaving(true); + try { + const response = await api.put('/tenant/auth', newConfig); + setAuthConfig(response.data.data); + setEditing(false); + toast.success('Authentication settings updated successfully'); + } catch (error) { + console.error('Failed to save auth config:', error); + toast.error(error.response?.data?.message || 'Failed to save authentication settings'); + } finally { + setSaving(false); + } + }; + + if (loading) { + return ( +
+
+
+
+
+
+
+
+
+ ); + } + + const authProvider = tenantConfig?.auth_provider || 'local'; + + return ( +
+ {/* Current Authentication Provider */} +
+
+
+
+

Authentication Provider

+

+ Current authentication method for this tenant +

+
+
+ + {authProvider.toUpperCase()} + + +
+
+ + {/* Provider Description */} +
+

+ {authProvider === 'local' && 'Users are managed directly in this system with username/password authentication.'} + {authProvider === 'saml' && 'Users authenticate through SAML Single Sign-On (SSO) provider.'} + {authProvider === 'oauth' && 'Users authenticate through OAuth provider (Google, Microsoft, etc.).'} + {authProvider === 'ldap' && 'Users authenticate through LDAP/Active Directory.'} + {authProvider === 'ad' && 'Users authenticate through Active Directory.'} +

+
+
+
+ + {/* Authentication Configuration */} + {editing && ( + setEditing(false)} + saving={saving} + /> + )} + + {/* User Role Mappings */} +
+
+

Role Mappings

+

+ Configure how external users are assigned roles in your system +

+ +
+ {authProvider === 'local' ? ( +
+ Role assignments for local users are managed in the Users tab. +
+ ) : ( + + )} +
+
+
+ + {/* Session Settings */} +
+
+

Session Settings

+

+ Configure session timeout and security settings +

+ +
+ +
+
+
+
+ ); +}; + +// Auth Provider Configuration Component +const AuthProviderConfig = ({ provider, config, onSave, onCancel, saving }) => { + const [formData, setFormData] = useState(config || {}); + + const handleSubmit = (e) => { + e.preventDefault(); + onSave(formData); + }; + + return ( +
+
+

+ {provider.toUpperCase()} Configuration +

+ +
+ {provider === 'saml' && ( + + )} + {provider === 'oauth' && ( + + )} + {provider === 'ldap' && ( + + )} + {provider === 'ad' && ( + + )} + +
+ + +
+ +
+
+ ); +}; + +// SAML Configuration +const SAMLConfig = ({ formData, setFormData }) => ( +
+
+ + setFormData({...formData, sso_url: e.target.value})} + className="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-primary-500 focus:border-primary-500 sm:text-sm" + placeholder="https://your-idp.com/sso" + /> +
+
+ + setFormData({...formData, entity_id: e.target.value})} + className="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-primary-500 focus:border-primary-500 sm:text-sm" + placeholder="your-app-entity-id" + /> +
+
+ +