@@ -61,21 +61,29 @@ function getOIDCConfig(): AuthConfig {
6161}
6262
6363/**
64- * Creates the configuration required for classic OAuth2 providers (e.g., Fineract).
64+ * Creates the configuration required for classic OAuth2 providers (e.g., Fineract, Keycloak ).
6565 * @returns {AuthConfig } OAuth2 configuration block.
6666 */
6767function getOAuth2Config ( ) : AuthConfig {
6868 const frontendUrl = window . location . origin ;
69+ const { serverUrl, authorizeUrl, tokenUrl, redirectUri, scope, appId } = environment . oauth ;
70+
71+ // Allow custom Keycloak realm via MIFOS_OAUTH_REALM (defaults to master)
72+ const keycloakRealm = ( window as any ) [ 'env' ] ?. [ 'MIFOS_OAUTH_REALM' ] || 'master' ;
73+ const resolvedAuthorizeUrl = authorizeUrl || `${ serverUrl } /auth/realms/${ keycloakRealm } /protocol/openid-connect/auth` ;
74+ const resolvedTokenUrl = tokenUrl || `${ serverUrl } /auth/realms/${ keycloakRealm } /protocol/openid-connect/token` ;
75+ const resolvedRedirectUri = redirectUri || `${ frontendUrl } /#/callback` ;
76+ const resolvedScope = scope || 'openid profile email' ;
6977
7078 return {
71- issuer : environment . oauth . serverUrl ,
72- loginUrl : environment . oauth . authorizeUrl ,
73- tokenEndpoint : environment . oauth . tokenUrl ,
74- redirectUri : environment . oauth . redirectUri ,
79+ issuer : serverUrl ,
80+ loginUrl : resolvedAuthorizeUrl ,
81+ tokenEndpoint : resolvedTokenUrl ,
82+ redirectUri : resolvedRedirectUri ,
7583 postLogoutRedirectUri : `${ frontendUrl } /#/login` ,
76- clientId : environment . oauth . appId ,
84+ clientId : appId ,
7785 responseType : 'code' ,
78- scope : environment . oauth . scope ,
86+ scope : resolvedScope ,
7987 useSilentRefresh : false ,
8088 oidc : false ,
8189 // Skip issuer validation for OAuth2 (non-OIDC) flows
0 commit comments