Skip to content

MODLOGSAML-219: Support MAX_AUTH_LIFETIME env var configuration#214

Merged
julianladisch merged 2 commits intomasterfrom
MODLOGSAML-219
Mar 12, 2026
Merged

MODLOGSAML-219: Support MAX_AUTH_LIFETIME env var configuration#214
julianladisch merged 2 commits intomasterfrom
MODLOGSAML-219

Conversation

@julianladisch
Copy link
Copy Markdown
Contributor

https://folio-org.atlassian.net/browse/MODLOGSAML-219

Support the MAX_AUTH_LIFETIME environment variable to configure the maximum authentication lifetime in seconds. This configuration applies to all tenants.

(For a per tenant based configuration see https://folio-org.atlassian.net/browse/MODLOGSAML-162 )

(mod-login-saml is a Okapi-only module that gets replaced with Keycloak in Eureka based FOLIO installations.)

https://folio-org.atlassian.net/browse/MODLOGSAML-219

Support the MAX_AUTH_LIFETIME environment variable to configure the maximum authentication lifetime in seconds. This configuration applies to all tenants.

(For a per tenant based configuration see https://folio-org.atlassian.net/browse/MODLOGSAML-162 )

(mod-login-saml is a Okapi-only module that gets replaced with Keycloak in Eureka based FOLIO installations.)
@barbaraloehle
Copy link
Copy Markdown
Contributor

There are questions concerning the formulation of the method

public static void setMaximumAuthenticationLifetime(String seconds)

What is the reason for not treating the possible NumberFormatException in an explicit manner?

try {
...
} catch (NumberFormatException numEx) {
  throw new NumberFormatException("Bad environmental variable value of
  "MAX_AUTH_LIFETIME" + seconds + ": " + numEx.getMessage());
}

If it is not necessary to throw a NumberFormatException
the default value DEFAULT_MAXIMUM_AUTHENTICATION_LIFETIME could be used.
(compare the suggestion of the Pull Request #213)

try {
...
} catch (NumberFormatException numEx) {
  logger.warn("Bad environmental variable value of MAX_AUTH_LIFETIME: {}. Replaced by the default value : {}}", seconds, numEx.getMessage(), DEFAULT_MAXIMUM_AUTHENTICATION_LIFETIME));
  maximumAuthenticationLifetime = DEFAULT_MAXIMUM_AUTHENTICATION_LIFETIME;
}

https://folio-org.atlassian.net/browse/MODLOGSAML-219

Old:

```
Caused by: java.lang.NumberFormatException: For input string: "foo"
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) ~[?:?]
        at java.base/java.lang.Long.parseLong(Long.java:709) ~[?:?]
        at java.base/java.lang.Long.parseLong(Long.java:832) ~[?:?]
        at org.folio.config.SamlClientLoader.setMaximumAuthenticationLifetime(SamlClientLoader.java:72) ~[mod-login-saml-fat.jar:?]
```

New:

```
Caused by: java.lang.NumberFormatException: Bad value of environmental variable MAX_AUTH_LIFETIME: "foo"
        at org.folio.config.SamlClientLoader.setMaximumAuthenticationLifetime(SamlClientLoader.java:75) ~[mod-login-saml-fat.jar:?]
```

Co-authored-by: barbaraloehle <113911583+barbaraloehle@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

@julianladisch julianladisch merged commit 1c742ca into master Mar 12, 2026
5 checks passed
@julianladisch julianladisch deleted the MODLOGSAML-219 branch March 12, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants