Skip to content

Commit a1a4fcd

Browse files
committed
introduce domain properties
1 parent bfb22da commit a1a4fcd

File tree

6 files changed

+65
-65
lines changed

6 files changed

+65
-65
lines changed

server/src/main/java/password/pwm/AppProperty.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,6 @@ public enum AppProperty
143143
HTTP_PARAM_NAME_SSO_OVERRIDE ( "http.parameter.ssoOverride" ),
144144
HTTP_PARAM_MAX_READ_LENGTH ( "http.parameter.maxReadLength" ),
145145
HTTP_PARAM_SESSION_VERIFICATION ( "http.parameter.sessionVerification" ),
146-
HTTP_PARAM_OAUTH_ACCESS_TOKEN ( "http.parameter.oauth.accessToken" ),
147-
HTTP_PARAM_OAUTH_ATTRIBUTES ( "http.parameter.oauth.attributes" ),
148-
HTTP_PARAM_OAUTH_CLIENT_ID ( "http.parameter.oauth.clientID" ),
149-
HTTP_PARAM_OAUTH_CLIENT_SECRET ( "http.parameter.oauth.clientSecret" ),
150-
HTTP_PARAM_OAUTH_CODE ( "http.parameter.oauth.code" ),
151-
HTTP_PARAM_OAUTH_EXPIRES ( "http.parameter.oauth.expires" ),
152-
HTTP_PARAM_OAUTH_RESPONSE_TYPE ( "http.parameter.oauth.responseType" ),
153-
HTTP_PARAM_OAUTH_REDIRECT_URI ( "http.parameter.oauth.redirectUri" ),
154-
HTTP_PARAM_OAUTH_REFRESH_TOKEN ( "http.parameter.oauth.refreshToken" ),
155-
HTTP_PARAM_OAUTH_SCOPE ( "http.parameter.oauth.scope" ),
156-
HTTP_PARAM_OAUTH_STATE ( "http.parameter.oauth.state" ),
157-
HTTP_PARAM_OAUTH_GRANT_TYPE ( "http.parameter.oauth.grantType" ),
158146
HTTP_DOWNLOAD_BUFFER_SIZE ( "http.download.buffer.size" ),
159147
HTTP_SESSION_RECYCLE_AT_AUTH ( "http.session.recycleAtAuth" ),
160148
HTTP_SERVLET_ENABLE_POST_REDIRECT_GET ( "http.servlet.enablePostRedirectGet" ),
@@ -224,11 +212,6 @@ public enum AppProperty
224212
NMAS_IGNORE_NMASCR_DURING_FORCECHECK ( "nmas.ignoreNmasCrDuringForceSetupCheck" ),
225213
NMAS_USE_LOCAL_SASL_FACTORY ( "nmas.useLocalSaslFactory" ),
226214
NMAS_FORCE_SASL_FACTORY_REGISTRATION ( "nmas.forceSaslFactoryRegistration" ),
227-
OAUTH_ID_REQUEST_TYPE ( "oauth.id.requestType" ),
228-
OAUTH_ID_ACCESS_GRANT_TYPE ( "oauth.id.accessGrantType" ),
229-
OAUTH_ID_REFRESH_GRANT_TYPE ( "oauth.id.refreshGrantType" ),
230-
OAUTH_ENABLE_TOKEN_REFRESH ( "oauth.enableTokenRefresh" ),
231-
OAUTH_RETURN_URL_OVERRIDE ( "oauth.returnUrlOverride" ),
232215

233216
/* Allows one older TOTP token - compensate for clock out of sync */
234217
TOTP_PAST_INTERVALS ( "otp.totp.pastIntervals" ),

server/src/main/java/password/pwm/DomainProperty.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ public enum DomainProperty
4444
HTTP_COOKIE_NONCE_NAME ( "http.cookie.nonce.name" ),
4545
HTTP_COOKIE_NONCE_LENGTH ( "http.cookie.nonce.length" ),
4646
HTTP_COOKIE_SAMESITE_VALUE ( "http.cookie.sameSite.value" ),
47+
HTTP_PARAM_OAUTH_ACCESS_TOKEN ( "http.parameter.oauth.accessToken" ),
48+
HTTP_PARAM_OAUTH_ATTRIBUTES ( "http.parameter.oauth.attributes" ),
49+
HTTP_PARAM_OAUTH_CLIENT_ID ( "http.parameter.oauth.clientID" ),
50+
HTTP_PARAM_OAUTH_CLIENT_SECRET ( "http.parameter.oauth.clientSecret" ),
51+
HTTP_PARAM_OAUTH_CODE ( "http.parameter.oauth.code" ),
52+
HTTP_PARAM_OAUTH_EXPIRES ( "http.parameter.oauth.expires" ),
53+
HTTP_PARAM_OAUTH_RESPONSE_TYPE ( "http.parameter.oauth.responseType" ),
54+
HTTP_PARAM_OAUTH_REDIRECT_URI ( "http.parameter.oauth.redirectUri" ),
55+
HTTP_PARAM_OAUTH_REFRESH_TOKEN ( "http.parameter.oauth.refreshToken" ),
56+
HTTP_PARAM_OAUTH_SCOPE ( "http.parameter.oauth.scope" ),
57+
HTTP_PARAM_OAUTH_STATE ( "http.parameter.oauth.state" ),
58+
HTTP_PARAM_OAUTH_GRANT_TYPE ( "http.parameter.oauth.grantType" ),
4759
LDAP_RESOLVE_CANONICAL_DN ( "ldap.resolveCanonicalDN" ),
4860
LDAP_CACHE_CANONICAL_ENABLE ( "ldap.cache.canonical.enable" ),
4961
LDAP_CACHE_CANONICAL_SECONDS ( "ldap.cache.canonical.seconds" ),
@@ -68,7 +80,12 @@ public enum DomainProperty
6880
LDAP_SEARCH_PARALLEL_ENABLE ( "ldap.search.parallel.enable" ),
6981
LDAP_SEARCH_PARALLEL_FACTOR ( "ldap.search.parallel.factor" ),
7082
LDAP_SEARCH_PARALLEL_THREAD_MAX ( "ldap.search.parallel.threadMax" ),
71-
LDAP_ORACLE_POST_TEMPPW_USE_CURRENT_TIME ( "ldap.oracle.postTempPasswordUseCurrentTime" ),;
83+
LDAP_ORACLE_POST_TEMPPW_USE_CURRENT_TIME ( "ldap.oracle.postTempPasswordUseCurrentTime" ),
84+
OAUTH_ID_REQUEST_TYPE ( "oauth.id.requestType" ),
85+
OAUTH_ID_ACCESS_GRANT_TYPE ( "oauth.id.accessGrantType" ),
86+
OAUTH_ID_REFRESH_GRANT_TYPE ( "oauth.id.refreshGrantType" ),
87+
OAUTH_ENABLE_TOKEN_REFRESH ( "oauth.enableTokenRefresh" ),
88+
OAUTH_RETURN_URL_OVERRIDE ( "oauth.returnUrlOverride" ),;
7289

7390
private final String key;
7491
private final String defaultValue;

server/src/main/java/password/pwm/http/servlet/oauth/OAuthConsumerServlet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
package password.pwm.http.servlet.oauth;
2222

23-
import password.pwm.AppProperty;
24-
import password.pwm.PwmDomain;
23+
import password.pwm.DomainProperty;
2524
import password.pwm.PwmConstants;
25+
import password.pwm.PwmDomain;
2626
import password.pwm.bean.ProfileID;
2727
import password.pwm.bean.UserIdentity;
2828
import password.pwm.config.DomainConfig;
@@ -197,7 +197,7 @@ protected void processAction( final PwmRequest pwmRequest )
197197
}
198198
}
199199

200-
final String requestCodeStr = pwmRequest.readParameterAsString( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_CODE ) );
200+
final String requestCodeStr = pwmRequest.readParameterAsString( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_CODE ) );
201201
LOGGER.trace( pwmRequest, () -> "received code from oauth server: " + requestCodeStr );
202202

203203
final OAuthResolveResults resolveResults;

server/src/main/java/password/pwm/http/servlet/oauth/OAuthMachine.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
package password.pwm.http.servlet.oauth;
2222

2323
import org.apache.http.HttpStatus;
24-
import password.pwm.AppProperty;
24+
import password.pwm.DomainProperty;
2525
import password.pwm.bean.LoginInfoBean;
2626
import password.pwm.bean.ProfileID;
2727
import password.pwm.bean.SessionLabel;
@@ -37,16 +37,16 @@
3737
import password.pwm.http.HttpMethod;
3838
import password.pwm.http.PwmRequest;
3939
import password.pwm.http.PwmURL;
40+
import password.pwm.http.servlet.PwmServletDefinition;
4041
import password.pwm.svc.httpclient.PwmHttpClient;
4142
import password.pwm.svc.httpclient.PwmHttpClientConfiguration;
4243
import password.pwm.svc.httpclient.PwmHttpClientRequest;
4344
import password.pwm.svc.httpclient.PwmHttpClientResponse;
44-
import password.pwm.http.servlet.PwmServletDefinition;
4545
import password.pwm.util.BasicAuthInfo;
4646
import password.pwm.util.java.CollectionUtil;
4747
import password.pwm.util.java.JavaHelper;
48-
import password.pwm.util.json.JsonFactory;
4948
import password.pwm.util.java.StringUtil;
49+
import password.pwm.util.json.JsonFactory;
5050
import password.pwm.util.logging.PwmLogger;
5151
import password.pwm.util.macro.MacroRequest;
5252

@@ -84,7 +84,7 @@ static Optional<OAuthRequestState> readOAuthRequestState(
8484
)
8585
throws PwmUnrecoverableException
8686
{
87-
final String requestStateStr = pwmRequest.readParameterAsString( pwmRequest.getDomainConfig().readAppProperty( AppProperty.HTTP_PARAM_OAUTH_STATE ) );
87+
final String requestStateStr = pwmRequest.readParameterAsString( pwmRequest.getDomainConfig().readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_STATE ) );
8888
if ( requestStateStr != null )
8989
{
9090
final OAuthState oAuthState = pwmRequest.decryptObject( requestStateStr, OAuthState.class );
@@ -116,17 +116,17 @@ public void redirectUserToOAuthServer(
116116
final DomainConfig config = pwmRequest.getDomainConfig();
117117
final String state = makeStateStringForRequest( pwmRequest, nextUrl, forgottenPasswordProfile );
118118
final String redirectUri = figureOauthSelfEndPointUrl( pwmRequest );
119-
final String code = config.readAppProperty( AppProperty.OAUTH_ID_REQUEST_TYPE );
119+
final String code = config.readDomainProperty( DomainProperty.OAUTH_ID_REQUEST_TYPE );
120120

121121
final Map<String, String> urlParams = new LinkedHashMap<>();
122-
urlParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_CLIENT_ID ), settings.getClientID() );
123-
urlParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_RESPONSE_TYPE ), code );
124-
urlParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_STATE ), state );
125-
urlParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_REDIRECT_URI ), redirectUri );
122+
urlParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_CLIENT_ID ), settings.getClientID() );
123+
urlParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_RESPONSE_TYPE ), code );
124+
urlParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_STATE ), state );
125+
urlParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_REDIRECT_URI ), redirectUri );
126126

127127
if ( StringUtil.notEmpty( settings.getScope() ) )
128128
{
129-
urlParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_SCOPE ), settings.getScope() );
129+
urlParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_SCOPE ), settings.getScope() );
130130
}
131131

132132
if ( userIdentity != null )
@@ -150,16 +150,16 @@ OAuthResolveResults makeOAuthResolveRequest(
150150
{
151151
final DomainConfig config = pwmRequest.getDomainConfig();
152152
final String requestUrl = settings.getCodeResolveUrl();
153-
final String grantType = config.readAppProperty( AppProperty.OAUTH_ID_ACCESS_GRANT_TYPE );
153+
final String grantType = config.readDomainProperty( DomainProperty.OAUTH_ID_ACCESS_GRANT_TYPE );
154154
final String redirectUri = figureOauthSelfEndPointUrl( pwmRequest );
155155
final String clientID = settings.getClientID();
156156

157157
final Map<String, String> requestParams = new HashMap<>();
158-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_CODE ), requestCode );
159-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_GRANT_TYPE ), grantType );
160-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_REDIRECT_URI ), redirectUri );
161-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_CLIENT_ID ), clientID );
162-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_CLIENT_SECRET ), settings.getSecret().getStringValue() );
158+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_CODE ), requestCode );
159+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_GRANT_TYPE ), grantType );
160+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_REDIRECT_URI ), redirectUri );
161+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_CLIENT_ID ), clientID );
162+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_CLIENT_SECRET ), settings.getSecret().getStringValue() );
163163

164164
final PwmHttpClientResponse restResults = makeHttpRequest( pwmRequest, "oauth code resolver", settings, requestUrl, requestParams, null );
165165

@@ -176,9 +176,9 @@ private OAuthResolveResults resolveResultsFromResponseBody(
176176
)
177177
{
178178
final DomainConfig config = pwmRequest.getDomainConfig();
179-
final String oauthExpiresParam = config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_EXPIRES );
180-
final String oauthAccessTokenParam = config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_ACCESS_TOKEN );
181-
final String refreshTokenParam = config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_REFRESH_TOKEN );
179+
final String oauthExpiresParam = config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_EXPIRES );
180+
final String oauthAccessTokenParam = config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_ACCESS_TOKEN );
181+
final String refreshTokenParam = config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_REFRESH_TOKEN );
182182

183183
final long expireSeconds = JavaHelper.silentParseLong( readAttributeFromBodyMap( resolveResponseBodyStr, oauthExpiresParam ), 0 );
184184
final String accessToken = readAttributeFromBodyMap( resolveResponseBodyStr, oauthAccessTokenParam );
@@ -199,11 +199,11 @@ private OAuthResolveResults makeOAuthRefreshRequest(
199199
{
200200
final DomainConfig config = pwmRequest.getDomainConfig();
201201
final String requestUrl = settings.getCodeResolveUrl();
202-
final String grantType = config.readAppProperty( AppProperty.OAUTH_ID_REFRESH_GRANT_TYPE );
202+
final String grantType = config.readDomainProperty( DomainProperty.OAUTH_ID_REFRESH_GRANT_TYPE );
203203

204204
final Map<String, String> requestParams = new HashMap<>();
205-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_REFRESH_TOKEN ), refreshCode );
206-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_GRANT_TYPE ), grantType );
205+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_REFRESH_TOKEN ), refreshCode );
206+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_GRANT_TYPE ), grantType );
207207

208208
final PwmHttpClientResponse restResults = makeHttpRequest( pwmRequest, "OAuth refresh resolver", settings, requestUrl, requestParams, null );
209209

@@ -221,8 +221,8 @@ String makeOAuthGetUserInfoRequest(
221221
final DomainConfig config = pwmRequest.getDomainConfig();
222222
final String requestUrl = settings.getAttributesUrl();
223223
final Map<String, String> requestParams = new HashMap<>();
224-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_ACCESS_TOKEN ), accessToken );
225-
requestParams.put( config.readAppProperty( AppProperty.HTTP_PARAM_OAUTH_ATTRIBUTES ), settings.getDnAttributeName() );
224+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_ACCESS_TOKEN ), accessToken );
225+
requestParams.put( config.readDomainProperty( DomainProperty.HTTP_PARAM_OAUTH_ATTRIBUTES ), settings.getDnAttributeName() );
226226
restResults = makeHttpRequest( pwmRequest, "OAuth userinfo", settings, requestUrl, requestParams, accessToken );
227227
}
228228

@@ -316,11 +316,11 @@ private static String figureOauthSelfEndPointUrl( final PwmRequest pwmRequest )
316316
final String redirectUri;
317317

318318
{
319-
final String returnUrlOverride = pwmRequest.getDomainConfig().readAppProperty( AppProperty.OAUTH_RETURN_URL_OVERRIDE );
319+
final String returnUrlOverride = pwmRequest.getDomainConfig().readDomainProperty( DomainProperty.OAUTH_RETURN_URL_OVERRIDE );
320320
final String siteURL = pwmRequest.getDomainConfig().readSettingAsString( PwmSetting.PWM_SITE_URL );
321321
if ( returnUrlOverride != null && !returnUrlOverride.trim().isEmpty() )
322322
{
323-
debugSource = "AppProperty(\"" + AppProperty.OAUTH_RETURN_URL_OVERRIDE.getKey() + "\")";
323+
debugSource = "DomainProperty(\"" + DomainProperty.OAUTH_RETURN_URL_OVERRIDE.getKey() + "\")";
324324
redirectUri = returnUrlOverride
325325
+ PwmServletDefinition.OAuthConsumer.servletUrl();
326326
}
@@ -358,7 +358,7 @@ public boolean checkOAuthExpiration(
358358
final PwmRequest pwmRequest
359359
) throws PwmUnrecoverableException
360360
{
361-
if ( !Boolean.parseBoolean( pwmRequest.getDomainConfig().readAppProperty( AppProperty.OAUTH_ENABLE_TOKEN_REFRESH ) ) )
361+
if ( !Boolean.parseBoolean( pwmRequest.getDomainConfig().readDomainProperty( DomainProperty.OAUTH_ENABLE_TOKEN_REFRESH ) ) )
362362
{
363363
return false;
364364
}

server/src/main/resources/password/pwm/AppProperty.properties

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,6 @@ http.parameter.passwordExpired=passwordExpired
152152
http.parameter.maxReadLength=10240
153153
http.parameter.sessionVerification=stickyRedirectTest
154154
http.parameter.ssoOverride=sso
155-
http.parameter.oauth.accessToken=access_token
156-
http.parameter.oauth.attributes=attributes
157-
http.parameter.oauth.clientID=client_id
158-
http.parameter.oauth.clientSecret=client_secret
159-
http.parameter.oauth.code=code
160-
http.parameter.oauth.expires=expires_in
161-
http.parameter.oauth.responseType=response_type
162-
http.parameter.oauth.redirectUri=redirect_uri
163-
http.parameter.oauth.refreshToken=refresh_token
164-
http.parameter.oauth.scope=scope
165-
http.parameter.oauth.state=state
166-
http.parameter.oauth.grantType=grant_type
167155
http.download.buffer.size=102400
168156
http.session.recycleAtAuth=true
169157
http.servlet.enablePostRedirectGet=true
@@ -207,11 +195,6 @@ nmas.threads.watchdogDebug=false
207195
nmas.ignoreNmasCrDuringForceSetupCheck=false
208196
nmas.useLocalSaslFactory=true
209197
nmas.forceSaslFactoryRegistration=true
210-
oauth.id.accessGrantType=authorization_code
211-
oauth.id.refreshGrantType=refresh_token
212-
oauth.id.requestType=code
213-
oauth.enableTokenRefresh=false
214-
oauth.returnUrlOverride=
215198
otp.totp.pastIntervals=1
216199
otp.totp.futureIntervals=1
217200
otp.totp.intervalSeconds=30

server/src/main/resources/password/pwm/DomainProperty.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ http.cookie.login.name=SESSION
3838
http.cookie.nonce.name=ID
3939
http.cookie.nonce.length=32
4040
http.cookie.sameSite.value=Strict
41+
http.parameter.oauth.accessToken=access_token
42+
http.parameter.oauth.attributes=attributes
43+
http.parameter.oauth.clientID=client_id
44+
http.parameter.oauth.clientSecret=client_secret
45+
http.parameter.oauth.code=code
46+
http.parameter.oauth.expires=expires_in
47+
http.parameter.oauth.responseType=response_type
48+
http.parameter.oauth.redirectUri=redirect_uri
49+
http.parameter.oauth.refreshToken=refresh_token
50+
http.parameter.oauth.scope=scope
51+
http.parameter.oauth.state=state
52+
http.parameter.oauth.grantType=grant_type
4153
ldap.resolveCanonicalDN=true
4254
ldap.cache.canonical.enable=true
4355
ldap.cache.canonical.seconds=600
@@ -63,3 +75,8 @@ ldap.search.parallel.enable=true
6375
ldap.search.parallel.factor=5
6476
ldap.search.parallel.threadMax=50
6577
ldap.oracle.postTempPasswordUseCurrentTime=false
78+
oauth.id.accessGrantType=authorization_code
79+
oauth.id.refreshGrantType=refresh_token
80+
oauth.id.requestType=code
81+
oauth.enableTokenRefresh=false
82+
oauth.returnUrlOverride=

0 commit comments

Comments
 (0)