Skip to content

Remove @Configuration meta-annotation from @Enable annotations #6613

Closed

Description

@vpavic

Currently, all Spring Security's @Enable annotations are meta-annotated with @Configuration. While convenient, this is not consistent with the rest of the Spring projects and most notably Spring Framework's @Enable annotations.

Additionally, the introduction of support for @Configuration(proxyBeanMethods=false) in Spring Framework provides a compelling reason to remove @Configuration meta-annotation from Spring Security's @Enable annotations and allow users to opt into their preferred configuration mode.

Activity

  1. added this to the 6.x milestone on Mar 14, 2019
  2. self-assigned this
    on Jul 5, 2022
  3. sjohnr commented on Jul 26, 2022

    @sjohnr
    Contributor

    Note that we will want to update the documentation examples to include @Configuration in places where it's currently missing.

  4. jsattler commented on Jul 27, 2022

    @jsattler
    Contributor

    @sjohnr I would like to help on this, as I was anyhow looking into the documentation part.

  5. assigned and unassigned on Jul 27, 2022
  6. sjohnr commented on Jul 27, 2022

    @sjohnr
    Contributor

    It's yours @jsattler! Keep in mind we'll want to update the reference documentation, javadoc and samples. I'll open a ticket to update the samples, and if you don't feel you can tackle that part just let me know.

  7. self-assigned this
    on Jul 27, 2022
  8. jsattler commented on Jul 27, 2022

    @jsattler
    Contributor

    @sjohnr I will take care of the reference documentation, javadoc and samples. The actual removal of the @Configuration from the @Enable* annotations will be tackled in a separate PR, as this seems to be a breaking change, correct? If it is tackled in a separate PR should I anyhow already update the tests using only @Enable*?

  9. sjohnr commented on Jul 29, 2022

    @sjohnr
    Contributor

    @jsattler yes, please do update tests if necessary! I think it can be done under this issue, but if you would like a separate issue let me know. And yes, this is a breaking change so I believe it will only be done in 6.0 (main). @rwinch can correct me if I'm wrong.

  10. added 3 commits that reference this issue on Jul 30, 2022
    e4f3586
    0b8fc6c
    040111a
  11. jsattler commented on Jul 30, 2022

    @jsattler
    Contributor

    Quite some files changed, hope that's okay for a single PR. If you have any suggestions to split this up, please let me know.

  12. rwinch commented on Aug 9, 2022

    @rwinch
    Member

    A note for self. I used the following to check for missing @Configuration:

    import re
    import sys
    
    
    enable_regex = r".*@Enable[a-zA-Z]+(Security|Authentication).*"
    config_regex = r".*@Configuration.*"
    A = 2
    B = 2
    
    file_name = sys.argv[1]
    try:
    	file = open(file_name, 'r')
    	lines = file.readlines()
    except Exception as err:
    	print ("Could not open file:", file_name, repr(err))
    	sys.exit()
    
    
    def find_regex_in_range(lines, regex, range):
    	for index in range:
    		peek_line = lines[index - 1]
    		if (re.match(regex, peek_line)):
    			return True
    	return False
    
    def print_range(lines, range):
    	for index in range:
    		peek_line = lines[index - 1]
    		print(f"{index} {peek_line}", end = "")
    
    line_count = 0
    
    for line in lines:
    	line_count += 1
    	if (re.match(enable_regex, line)):
    		before_range = range(line_count - B, line_count)
    		after_range = range(line_count + 1, line_count + A + 1)
    		if (find_regex_in_range(lines, config_regex, before_range) or find_regex_in_range(lines, config_regex, after_range)):
    			continue
    		print (f"{file_name}")
    		print ("---")
    		print_range(lines, before_range)
    		print (f"{line_count} {line}", end = "")
    		print_range(lines, after_range)
    		print ("---")

    Then run

     rg . -l | xargs -I{} python find-enable.py
    
  13. added a commit that references this issue on Aug 9, 2022
  14. removed this from the 6.0.x milestone on Aug 9, 2022
  15. rwinch commented on Aug 9, 2022

    @rwinch
    Member

    Closing in favor of gh-11653

  16. added a commit that references this issue on Aug 25, 2022
  17. added a commit that references this issue on Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

in: configAn issue in spring-security-configstatus: duplicateA duplicate of another issuetype: breaks-passivityA change that breaks passivity with the previous releasetype: enhancementA general enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions