@@ -163,12 +163,10 @@ static const char *oidc_set_int_slot(cmd_parms *cmd, void *struct_ptr,
163163}
164164
165165/*
166- * set a URL value in the server config
166+ * set a URL value in a config record
167167 */
168168static const char * oidc_set_url_slot_type (cmd_parms * cmd , void * ptr ,
169169 const char * arg , const char * type ) {
170- oidc_cfg * cfg = (oidc_cfg * ) ap_get_module_config (
171- cmd -> server -> module_config , & auth_openidc_module );
172170 apr_uri_t url ;
173171 if (apr_uri_parse (cmd -> pool , arg , & url ) != APR_SUCCESS ) {
174172 return apr_psprintf (cmd -> pool ,
@@ -200,21 +198,32 @@ static const char *oidc_set_url_slot_type(cmd_parms *cmd, void *ptr,
200198 "oidc_set_url_slot_type: configuration value '%s' could not be parsed as a HTTP/HTTPs URL (no hostname set, check your slashes)!" ,
201199 arg );
202200 }
203- return ap_set_string_slot (cmd , cfg , arg );
201+ return ap_set_string_slot (cmd , ptr , arg );
204202}
205203
206204/*
207205 * set a HTTPS value in the server config
208206 */
209207static const char * oidc_set_https_slot (cmd_parms * cmd , void * ptr ,
210208 const char * arg ) {
211- return oidc_set_url_slot_type (cmd , ptr , arg , "https" );
209+ oidc_cfg * cfg = (oidc_cfg * ) ap_get_module_config (
210+ cmd -> server -> module_config , & auth_openidc_module );
211+ return oidc_set_url_slot_type (cmd , cfg , arg , "https" );
212212}
213213
214214/*
215215 * set a HTTPS/HTTP value in the server config
216216 */
217217static const char * oidc_set_url_slot (cmd_parms * cmd , void * ptr , const char * arg ) {
218+ oidc_cfg * cfg = (oidc_cfg * ) ap_get_module_config (
219+ cmd -> server -> module_config , & auth_openidc_module );
220+ return oidc_set_url_slot_type (cmd , cfg , arg , NULL );
221+ }
222+
223+ /*
224+ * set a HTTPS/HTTP value in the directory config
225+ */
226+ static const char * oidc_set_url_slot_dir_cfg (cmd_parms * cmd , void * ptr , const char * arg ) {
218227 return oidc_set_url_slot_type (cmd , ptr , arg , NULL );
219228}
220229
@@ -710,7 +719,6 @@ void *oidc_create_server_config(apr_pool_t *pool, server_rec *svr) {
710719 c -> merged = FALSE;
711720
712721 c -> redirect_uri = NULL ;
713- c -> discover_url = NULL ;
714722 c -> default_sso_url = NULL ;
715723 c -> default_slo_url = NULL ;
716724 c -> public_keys = NULL ;
@@ -819,8 +827,6 @@ void *oidc_merge_server_config(apr_pool_t *pool, void *BASE, void *ADD) {
819827
820828 c -> redirect_uri =
821829 add -> redirect_uri != NULL ? add -> redirect_uri : base -> redirect_uri ;
822- c -> discover_url =
823- add -> discover_url != NULL ? add -> discover_url : base -> discover_url ;
824830 c -> default_sso_url =
825831 add -> default_sso_url != NULL ?
826832 add -> default_sso_url : base -> default_sso_url ;
@@ -1128,6 +1134,7 @@ void *oidc_merge_server_config(apr_pool_t *pool, void *BASE, void *ADD) {
11281134 */
11291135void * oidc_create_dir_config (apr_pool_t * pool , char * path ) {
11301136 oidc_dir_cfg * c = apr_pcalloc (pool , sizeof (oidc_dir_cfg ));
1137+ c -> discover_url = NULL ;
11311138 c -> cookie = OIDC_DEFAULT_COOKIE ;
11321139 c -> cookie_path = OIDC_DEFAULT_COOKIE_PATH ;
11331140 c -> authn_header = OIDC_DEFAULT_AUTHN_HEADER ;
@@ -1143,6 +1150,8 @@ void *oidc_merge_dir_config(apr_pool_t *pool, void *BASE, void *ADD) {
11431150 oidc_dir_cfg * c = apr_pcalloc (pool , sizeof (oidc_dir_cfg ));
11441151 oidc_dir_cfg * base = BASE ;
11451152 oidc_dir_cfg * add = ADD ;
1153+ c -> discover_url =
1154+ add -> discover_url != NULL ? add -> discover_url : base -> discover_url ;
11461155 c -> cookie = (
11471156 apr_strnatcasecmp (add -> cookie , OIDC_DEFAULT_COOKIE ) != 0 ?
11481157 add -> cookie : base -> cookie );
@@ -1681,10 +1690,6 @@ const command_rec oidc_config_cmds[] = {
16811690 (void * )APR_OFFSETOF (oidc_cfg , redirect_uri ),
16821691 RSRC_CONF ,
16831692 "Define the Redirect URI (e.g.: https://localhost:9031/protected/example/)" ),
1684- AP_INIT_TAKE1 ("OIDCDiscoverURL" , oidc_set_url_slot ,
1685- (void * )APR_OFFSETOF (oidc_cfg , discover_url ),
1686- RSRC_CONF ,
1687- "Defines an external IDP Discovery page" ),
16881693 AP_INIT_TAKE1 ("OIDCDefaultURL" , oidc_set_url_slot ,
16891694 (void * )APR_OFFSETOF (oidc_cfg , default_sso_url ),
16901695 RSRC_CONF ,
@@ -1828,23 +1833,6 @@ const command_rec oidc_config_cmds[] = {
18281833 RSRC_CONF ,
18291834 "Scrub user name and claim headers from the user's request." ),
18301835
1831- AP_INIT_TAKE1 ("OIDCAuthNHeader" , ap_set_string_slot ,
1832- (void * ) APR_OFFSETOF (oidc_dir_cfg , authn_header ),
1833- RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1834- "Specify the HTTP header variable to set with the name of the authenticated user. By default no explicit header is added but Apache's default REMOTE_USER will be set." ),
1835- AP_INIT_TAKE1 ("OIDCCookiePath" , ap_set_string_slot ,
1836- (void * ) APR_OFFSETOF (oidc_dir_cfg , cookie_path ),
1837- RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1838- "Define the cookie path for the session cookie." ),
1839- AP_INIT_TAKE1 ("OIDCCookie" , ap_set_string_slot ,
1840- (void * ) APR_OFFSETOF (oidc_dir_cfg , cookie ),
1841- RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1842- "Define the cookie name for the session cookie." ),
1843- AP_INIT_FLAG ("OIDCReturn401" , ap_set_flag_slot ,
1844- (void * ) APR_OFFSETOF (oidc_dir_cfg , return401 ),
1845- RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1846- "Indicates whether a user will be redirected to the Provider when not authenticated (Off) or a 401 will be returned (On)." ),
1847-
18481836 AP_INIT_TAKE1 ("OIDCCacheType" , oidc_set_cache_type ,
18491837 (void * )APR_OFFSETOF (oidc_cfg , cache ), RSRC_CONF ,
18501838 "Cache type; must be one of \"file\", \"memcache\" or \"shm\"." ),
@@ -1878,10 +1866,32 @@ const command_rec oidc_config_cmds[] = {
18781866 RSRC_CONF ,
18791867 "Redis server used for caching (<hostname>[:<port>])" ),
18801868#endif
1869+
1870+ AP_INIT_TAKE1 ("OIDCDiscoverURL" , oidc_set_url_slot_dir_cfg ,
1871+ (void * )APR_OFFSETOF (oidc_dir_cfg , discover_url ),
1872+ RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1873+ "Defines an external IDP Discovery page" ),
18811874 AP_INIT_ITERATE ("OIDCPassCookies" ,
18821875 oidc_set_pass_cookies ,
18831876 (void * ) APR_OFFSETOF (oidc_dir_cfg , pass_cookies ),
18841877 RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
18851878 "Specify cookies that need to be passed from the browser on to the backend to the OP/AS." ),
1879+ AP_INIT_TAKE1 ("OIDCAuthNHeader" , ap_set_string_slot ,
1880+ (void * ) APR_OFFSETOF (oidc_dir_cfg , authn_header ),
1881+ RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1882+ "Specify the HTTP header variable to set with the name of the authenticated user. By default no explicit header is added but Apache's default REMOTE_USER will be set." ),
1883+ AP_INIT_TAKE1 ("OIDCCookiePath" , ap_set_string_slot ,
1884+ (void * ) APR_OFFSETOF (oidc_dir_cfg , cookie_path ),
1885+ RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1886+ "Define the cookie path for the session cookie." ),
1887+ AP_INIT_TAKE1 ("OIDCCookie" , ap_set_string_slot ,
1888+ (void * ) APR_OFFSETOF (oidc_dir_cfg , cookie ),
1889+ RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1890+ "Define the cookie name for the session cookie." ),
1891+ AP_INIT_FLAG ("OIDCReturn401" , ap_set_flag_slot ,
1892+ (void * ) APR_OFFSETOF (oidc_dir_cfg , return401 ),
1893+ RSRC_CONF |ACCESS_CONF |OR_AUTHCFG ,
1894+ "Indicates whether a user will be redirected to the Provider when not authenticated (Off) or a 401 will be returned (On)." ),
1895+
18861896 { NULL }
18871897};
0 commit comments