Skip to content

Auto-configure a JwtAuthenticationConverter #33689

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

Closed
hannah23280 opened this issue Jan 4, 2023 · 2 comments
Closed

Auto-configure a JwtAuthenticationConverter #33689

hannah23280 opened this issue Jan 4, 2023 · 2 comments
Labels
status: superseded An issue that has been superseded by another

Comments

@hannah23280
Copy link

hannah23280 commented Jan 4, 2023

Hi,
I learn the below way to customize the authority prefix and claim name. Would like to suggest provide configuration properties to allow developer to easily customize the JwtAuthenticationConverter, so that developer does not have to write these boilerplate codes

@Bean
    public JwtAuthenticationConverter jwtAuthenticationConverter() {
        JwtGrantedAuthoritiesConverter grantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
        grantedAuthoritiesConverter.setAuthorityPrefix("");
        //grantedAuthoritiesConverter.setAuthoritiesClaimName("role");
        JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter();
        jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(grantedAuthoritiesConverter);
        return jwtAuthenticationConverter;
    }
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 4, 2023
@wilkinsona
Copy link
Member

Thanks for the suggestion. It looks like we could auto-configure a JwtAuthenticationConverter bean if there's no such existing bean in the context and a property has been set for the principal claim name, the authority prefix, or the authorities claim name.

@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 5, 2023
@wilkinsona wilkinsona added this to the 3.x milestone Jan 5, 2023
@wilkinsona wilkinsona changed the title Configuration Properties for the JWT Authentication Converter Auto-configure a JwtAuthenticatonConverter Jan 5, 2023
@wilkinsona wilkinsona changed the title Auto-configure a JwtAuthenticatonConverter Auto-configure a JwtAuthenticationConverter Jan 5, 2023
ykardziyaka added a commit to ykardziyaka/spring-boot that referenced this issue Oct 30, 2023
@mhalbritter
Copy link
Contributor

Superseded by #38105.

@mhalbritter mhalbritter closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
@mhalbritter mhalbritter removed this from the 3.x milestone Jan 10, 2024
@mhalbritter mhalbritter added status: superseded An issue that has been superseded by another and removed type: enhancement A general enhancement labels Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants