Forum Discussion

lucastancapiano's avatar
Regular Visitor
9 months ago

How import roles

Hi all, I'm working with Swagger open API 2.2.15 in Java through this configuration:



public OpenAPI openAPI() {

    return new OpenAPI().components(new Components().addSecuritySchemes(OAUTH_SCHEME_NAME, createOAuthScheme()))

         .addSecurityItem(new SecurityRequirement().addList(OAUTH_SCHEME_NAME))

         .info(new Info().title("Cities Generator").description("Web console").version("1.0"));



private SecurityScheme createOAuthScheme() {

     OAuthFlows flows = createOAuthFlows();

     return new SecurityScheme().type(SecurityScheme.Type.OAUTH2).flows(flows);



private OAuthFlows createOAuthFlows() {

    OAuthFlow flow = createAuthorizationCodeFlow();

    return new OAuthFlows().implicit(flow);



private OAuthFlow createAuthorizationCodeFlow() {

     return new OAuthFlow().authorizationUrl(authServerUrl + "/realms/" + realm + "/protocol/openid-connect/auth");



I would understand how to import the roles in the subject. Actually, this configuration adds to my user an anonymous role ROLE_anonymous but I would the authorities imported from my external system. The login is ok

No RepliesBe the first to reply