Compare commits

...

2 commits

Author SHA1 Message Date
Nadim Ritter
600e805240 Merge branch 'dev-2.0' of github.com:SafeExamBrowser/seb-server into redesign 2024-07-30 11:44:13 +02:00
Nadim Ritter
0da6a2356f redesign add security scheme for swagger 2024-07-18 13:52:27 +02:00

View file

@ -13,6 +13,11 @@ import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.OAuthFlow;
import io.swagger.v3.oas.models.security.OAuthFlows;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.catalina.filters.RemoteIpFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -117,6 +122,21 @@ public class WebServiceSecurityConfig extends WebSecurityConfigurerAdapter {
return new RemoteIpFilter();
}
@Bean
public OpenAPI cutomOpenApi(){
return new OpenAPI()
.components(new Components()
.addSecuritySchemes("oauth2", new SecurityScheme()
.type(SecurityScheme.Type.OAUTH2)
.scheme("bearer")
.in(SecurityScheme.In.HEADER)
.bearerFormat("jwt")
.flows(new OAuthFlows().password(new OAuthFlow().tokenUrl("/oauth/token")))
)
);
}
@Bean
public AccessTokenConverter accessTokenConverter() {
final DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();