Skip to content

[JEP-227] Replace Acegi Security with Spring Security & upgrade Spring Framework#4848

Merged
jeffret-b merged 168 commits intojenkinsci:masterfrom
jglick:spring-5303
Nov 6, 2020
Merged

[JEP-227] Replace Acegi Security with Spring Security & upgrade Spring Framework#4848
jeffret-b merged 168 commits intojenkinsci:masterfrom
jglick:spring-5303

Conversation

@jglick
Copy link
Member

@jglick jglick commented Jul 15, 2020

JEP-227

Proposed changelog entries

  • Jenkins now uses Spring Security rather than its predecessor, Acegi Security. Other bundled Spring libraries are also updated.

Proposed upgrade guidelines

https://www.jenkins.io/blog/2020/11/10/spring-xstream/

See the compatibility table.

Desired reviewers

@jenkinsci/core

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

@jglick jglick requested review from Wadeck and daniel-beck July 15, 2020 23:03
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a good approach

@jglick

This comment has been minimized.

@res0nance res0nance added the work-in-progress The PR is under active development, not ready to the final review label Jul 20, 2020
// this way in Spring and what most developers would expect to happen.

final Set<Class> interfaces = ClassUtils.getAllInterfacesAsSet(instance);
final Set<Class<?>> interfaces = ClassUtils.getAllInterfacesAsSet(instance);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a signature change in Spring.

// we just authenticate anonymous users as such,
// so that later authorization can reject them if so configured
AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider("anonymous");
AuthenticationManager authenticationManager = new ProviderManager(authenticator, rmap, aap);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just translating the Groovy into equivalent Java.

import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;

public class PrincipalSid implements Sid {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reimplementing these from scratch. Only used from SidAcl.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and cloudbees/bluesteel -> TeamSecurity.java (which is not using SidACL in that class but underlying more it it is). (not sure you saw that or not)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ought to be compatible AFAICT.

*
* @author Kohsuke Kawaguchi
*/
public class BindAuthenticator2 extends BindAuthenticator {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to have been unused, and I do not want to depend on Spring Security modules for LDAP here; belongs in the ldap plugin only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction: was used by the ldap plugin, and should have been there all along (see 9b4cd99 & 32cba8f). Correcting in jenkinsci/ldap-plugin@a5267e6.

* @deprecated TODO replacement
*/
@Deprecated
public interface UserDetailsService extends org.springframework.security.core.userdetails.UserDetailsService {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might just get deleted, TBD.

@jeffret-b jeffret-b merged commit a9ca5ef into jenkinsci:master Nov 6, 2020
@jglick jglick deleted the spring-5303 branch November 6, 2020 18:33
jglick added a commit to jglick/jenkins.io that referenced this pull request Nov 6, 2020

public static void setProtectedFieldValue(String protectedField, Object object, Object newValue) {
try {
org.apache.commons.lang.reflect.FieldUtils.writeField(object, protectedField, newValue, true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #5105

import jenkins.util.io.OnMaster;
import net.sf.json.JSONObject;

import org.acegisecurity.Authentication;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timja
Copy link
Member

timja commented Mar 22, 2021

@jglick / @jvz looks like the credentials API needs updating? https://github.com/jenkinsci/credentials-plugin/blob/3a603dec20412ccce754d9cbbd835d890ca06ee5/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java#L517

It takes the acegi security Authentication as a parameter and I can't avoid a deprecation warning in my plugin because of this.

@jglick
Copy link
Member Author

jglick commented Mar 22, 2021

It could be updated, sure.

@jglick jglick mentioned this pull request Jan 14, 2022
@basil basil mentioned this pull request Mar 13, 2022
11 tasks
Vlatombe added a commit to Vlatombe/credentials-plugin that referenced this pull request Oct 23, 2023
This is the implementation of
jenkinsci/jenkins#4848 for Credentials API. This
will allow consumers of the credentials API to remove references to
deprecated acegi APIs.
Vlatombe added a commit to Vlatombe/credentials-plugin that referenced this pull request Oct 23, 2023
This is the implementation of
jenkinsci/jenkins#4848 for Credentials API. This
will allow consumers of the credentials API to remove references to
deprecated acegi APIs.
Vlatombe added a commit to Vlatombe/credentials-plugin that referenced this pull request Oct 23, 2023
This is the implementation of
jenkinsci/jenkins#4848 for Credentials API. This
will allow consumers of the credentials API to remove references to
deprecated acegi APIs.
jglick pushed a commit to jenkinsci/credentials-plugin that referenced this pull request Oct 27, 2023
…APIs (#490)

* [JEP-227] Replace Acegi Security with Spring Security APIs

This is the implementation of
jenkinsci/jenkins#4848 for Credentials API. This
will allow consumers of the credentials API to remove references to
deprecated acegi APIs.

* Fix spotbugs issues

* Fix reviews

* Rename methods appropriately

* Fixup some javadocs.

* Remove unused method.

* Forgot to remove usages.

* Remove CredentialsProvider#getCredentials2(Class, ItemGroup, Authentication) in favor of CredentialsProvider#getCredentials2(Class, ItemGroup, Authentication, List)

* Fix a few null checks while we are here.

* Restore a method I deleted by mistake.

* Add tests for new signatures

* Rename *2 methods to *InItem/*InItemGroup to avoid ambiguous signatures

* Update docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file developer Changes which impact plugin developers major-rfe For changelog: Major enhancement. Will be highlighted on the top plugin-api-changes Changes the API of Jenkins available for use in plugins. ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback removed This PR removes a feature or a public API squash-merge-me Unclean or useless commit history, should be merged only with squash-merge upgrade-guide-needed This change might be breaking in rare circumstances, an entry in the LTS upgrade guide is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants