-
-
Notifications
You must be signed in to change notification settings - Fork 109
Introduce OidcProperty extension point
#644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
642e45c
033b036
f146ea3
0f1bad9
e37b046
efcabaf
6749a67
e7fe954
a7a66e9
5bbabdf
ac88b2a
33a0e8e
f10abec
76399d6
0ca5d07
a1a8c5e
0ba995f
0f36904
0d6d19c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Vlatombe marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inlined into |
This file was deleted.
|
Vlatombe marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package org.jenkinsci.plugins.oic; | ||
|
|
||
| import edu.umd.cs.findbugs.annotations.NonNull; | ||
| import hudson.model.AbstractDescribableImpl; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import org.springframework.security.core.Authentication; | ||
|
|
||
| /** | ||
| * Represents a property that can be configured for OIDC authentication. | ||
| */ | ||
| public abstract class OicProperty extends AbstractDescribableImpl<OicProperty> { | ||
| /** | ||
| * @return a new execution for this property, holding any required state. | ||
| */ | ||
| @NonNull | ||
| public OicPropertyExecution newExecution(@NonNull OicServerConfiguration serverConfiguration) { | ||
| return new EmptyExecution(); | ||
| } | ||
|
|
||
| private record EmptyExecution() implements OicPropertyExecution {} | ||
|
|
||
| /** | ||
| * Allows a property to authenticate the user. | ||
| * @see org.jenkinsci.plugins.oic.properties.EscapeHatch | ||
| */ | ||
| public Optional<Authentication> authenticate(Authentication authentication) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For bearer token, I think you would need to add a way to plug a new filter into the authentication chain (doesn't exist currently, I only added the bare minumum for |
||
| return Optional.empty(); | ||
| } | ||
|
|
||
| /** | ||
| * Allows a property to contribute additional query parameters to the logout request. | ||
| */ | ||
| @NonNull | ||
| public List<LogoutQueryParameter> contributeLogoutQueryParameters() { | ||
| return List.of(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||||||
| package org.jenkinsci.plugins.oic; | ||||||||||
|
|
||||||||||
| import edu.umd.cs.findbugs.annotations.NonNull; | ||||||||||
| import hudson.ExtensionList; | ||||||||||
| import hudson.ExtensionPoint; | ||||||||||
| import hudson.model.Descriptor; | ||||||||||
| import org.pac4j.oidc.config.OidcConfiguration; | ||||||||||
|
|
||||||||||
| public abstract class OicPropertyDescriptor extends Descriptor<OicProperty> implements ExtensionPoint { | ||||||||||
| public static ExtensionList<OicPropertyDescriptor> all() { | ||||||||||
| return ExtensionList.lookup(OicPropertyDescriptor.class); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Allows the property to restrict its applicability depending on the context (for example, FIPS) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I first saw this I was confused, perhaps some more docs on why this is here and when to use it vs not registering your Descriptor would help? e.g.
Suggested change
|
||||||||||
| */ | ||||||||||
| public boolean isApplicable() { | ||||||||||
| return true; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * This method gets called if the property is not configured explicitly. For example, providing a default value. | ||||||||||
| */ | ||||||||||
| public void getFallbackConfiguration( | ||||||||||
| @NonNull OicServerConfiguration serverConfiguration, @NonNull OidcConfiguration configuration) { | ||||||||||
| // no-op | ||||||||||
| } | ||||||||||
|
Comment on lines
+24
to
+
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems strange to handle this differently to an actual property. Was there a reason that an
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An |
||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.jenkinsci.plugins.oic; | ||
|
|
||
| import edu.umd.cs.findbugs.annotations.NonNull; | ||
| import org.pac4j.oidc.client.OidcClient; | ||
| import org.pac4j.oidc.config.OidcConfiguration; | ||
|
|
||
| public interface OicPropertyExecution { | ||
| /** | ||
| * Customize the OIDC configuration. | ||
| * | ||
| * @param configuration the OIDC configuration to customize | ||
| */ | ||
| default void customizeConfiguration(@NonNull OidcConfiguration configuration) {} | ||
|
|
||
| /** | ||
| * Customize the OIDC client. | ||
| * <br/> | ||
| * Always called after {@link #customizeConfiguration(OidcConfiguration)}. | ||
| * | ||
| * @param client the OIDC client to customize | ||
| */ | ||
| default void customizeClient(@NonNull OidcClient client) {} | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually moved to
EscapeHatch