[java-oidc-common] branch main updated: JCOMOIDC-124 - Profile configuration setting for limiting initial access token to self
Henri Mikkonen
henri.mikkonen at iki.fi
Fri Oct 4 09:56:47 UTC 2024
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-oidc-common.
View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=e6d718db2427d68e9bee758a3a948bfb99330f42
The following commit(s) were added to refs/heads/main by this push:
new e6d718d JCOMOIDC-124 - Profile configuration setting for limiting initial access token to self
e6d718d is described below
commit e6d718db2427d68e9bee758a3a948bfb99330f42
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Fri Oct 4 12:56:18 2024 +0300
JCOMOIDC-124 - Profile configuration setting for limiting initial access token to self
https://shibboleth.atlassian.net/browse/JCOMOIDC-124
New configuration setting flag 'limitInitialAccessTokenToSelf' for OAUTH2.Token.
---
.../LimitInitialAccessTokenToSelfPredicate.java | 47 ++++++++++++++++++++++
.../oauth2/config/OAuth2TokenConfiguration.java | 12 ++++++
.../impl/DefaultOAuth2TokenConfiguration.java | 34 ++++++++++++++++
3 files changed, 93 insertions(+)
diff --git a/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/config/logic/LimitInitialAccessTokenToSelfPredicate.java b/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/config/logic/LimitInitialAccessTokenToSelfPredicate.java
new file mode 100644
index 0000000..7078b52
--- /dev/null
+++ b/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/config/logic/LimitInitialAccessTokenToSelfPredicate.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.profile.config.logic;
+
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import net.shibboleth.profile.config.ProfileConfiguration;
+import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.profile.context.logic.AbstractRelyingPartyPredicate;
+import net.shibboleth.oidc.profile.oauth2.config.OAuth2TokenConfiguration;
+
+/**
+ * A predicate implementation that forwards to
+ * {@link OAuth2TokenConfiguration#isLimitInitialAccessTokenToSelf(ProfileRequestContext)}.
+ *
+ * @since 3.2.0
+ */
+public class LimitInitialAccessTokenToSelfPredicate extends AbstractRelyingPartyPredicate {
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean test(@Nullable final ProfileRequestContext input) {
+ final RelyingPartyContext rpc = getRelyingPartyContextLookupStrategy().apply(input);
+ if (rpc != null) {
+ final ProfileConfiguration pc = rpc.getProfileConfig();
+ if (pc instanceof OAuth2TokenConfiguration otc) {
+ return otc.isLimitInitialAccessTokenToSelf(input);
+ }
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/oauth2/config/OAuth2TokenConfiguration.java b/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/oauth2/config/OAuth2TokenConfiguration.java
index 66d48b9..6c54873 100644
--- a/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/oauth2/config/OAuth2TokenConfiguration.java
+++ b/oidc-common-profile-api/src/main/java/net/shibboleth/oidc/profile/oauth2/config/OAuth2TokenConfiguration.java
@@ -91,4 +91,16 @@ public interface OAuth2TokenConfiguration extends OIDCSSOProviderConfiguration {
@ConfigurationSetting(name="issueIdTokenViaRefreshToken")
boolean isIssueIdTokenViaRefreshToken(@Nullable final ProfileRequestContext profileRequestContext);
+ /**
+ * Get whether the initial access token audience is solely to self (i.e. UserInfo) use.
+ *
+ * @param profileRequestContext profile request context
+ *
+ * @return whether initial access token audience is solely to self (i.e. UserInfo) use
+ *
+ * @since 3.2.0
+ */
+ @ConfigurationSetting(name="limitInitialAccessTokenToSelf")
+ boolean isLimitInitialAccessTokenToSelf(@Nullable final ProfileRequestContext profileRequestContext);
+
}
diff --git a/oidc-common-profile-impl/src/main/java/net/shibboleth/oidc/profile/oauth2/config/impl/DefaultOAuth2TokenConfiguration.java b/oidc-common-profile-impl/src/main/java/net/shibboleth/oidc/profile/oauth2/config/impl/DefaultOAuth2TokenConfiguration.java
index a235592..617e899 100644
--- a/oidc-common-profile-impl/src/main/java/net/shibboleth/oidc/profile/oauth2/config/impl/DefaultOAuth2TokenConfiguration.java
+++ b/oidc-common-profile-impl/src/main/java/net/shibboleth/oidc/profile/oauth2/config/impl/DefaultOAuth2TokenConfiguration.java
@@ -62,6 +62,9 @@ public class DefaultOAuth2TokenConfiguration extends AbstractOIDCSSOConfiguratio
/** Whether issue id_token when refresh_token is used. */
@Nonnull private Predicate<ProfileRequestContext> issueIdTokenViaRefreshTokenPredicate;
+ /** Whether initial access token audience is solely to self (i.e. UserInfo) use. */
+ @Nonnull private Predicate<ProfileRequestContext> limitInitialAccessTokenToSelfPredicate;
+
/**
* Constructor.
*/
@@ -81,6 +84,7 @@ public class DefaultOAuth2TokenConfiguration extends AbstractOIDCSSOConfiguratio
refreshTokenClaimsSetManipulationStrategyLookupStrategy = FunctionSupport.constant(null);
enforceRefreshTokenRotationPredicate = PredicateSupport.alwaysFalse();
issueIdTokenViaRefreshTokenPredicate = PredicateSupport.alwaysTrue();
+ limitInitialAccessTokenToSelfPredicate = PredicateSupport.alwaysFalse();
}
@Override
@@ -208,4 +212,34 @@ public class DefaultOAuth2TokenConfiguration extends AbstractOIDCSSOConfiguratio
issueIdTokenViaRefreshTokenPredicate = Constraint.isNotNull(condition, "Condition cannot be null");
}
+ /** {@inheritDoc} */
+ @Override
+ public boolean isLimitInitialAccessTokenToSelf(
+ @Nullable final ProfileRequestContext profileRequestContext) {
+ return limitInitialAccessTokenToSelfPredicate.test(profileRequestContext);
+ }
+
+ /**
+ * Set whether the initial access token audience is solely to self (i.e. UserInfo) use.
+ *
+ * @param flag flag to set
+ *
+ * @since 3.2.0
+ */
+ public void setLimitInitialAccessTokenToSelf(final boolean flag) {
+ limitInitialAccessTokenToSelfPredicate =
+ flag ? PredicateSupport.alwaysTrue() : PredicateSupport.alwaysFalse();
+ }
+
+ /**
+ * Set condition for whether initial access token audience is solely to self (i.e. UserInfo) use.
+ *
+ * @param condition condition to set
+ *
+ * @since 3.2.0
+ */
+ public void setLimitInitialAccessTokenToSelfPredicate(
+ @Nonnull final Predicate<ProfileRequestContext> condition) {
+ limitInitialAccessTokenToSelfPredicate = Constraint.isNotNull(condition, "Condition cannot be null");
+ }
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list