Hello Experts,
Is there a way to add or restrict /rest/v2/swagger-ui.html with HTTP Basic Authentication?
Thanks
Anil
Request clarification before answering.
Hi Anilkumar
Please take a look on below link, it would be helpful.
https://swagger.io/docs/specification/authentication/basic-authentication/
Thanks,
Gaurav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@areddy34 : yes it is possible to restrict UI with basic authentication. You have to add following configuration in security-v2-spring.xml of commercewebservices extension. After adding following configuration, browser will prompt for username password. The other apis (Cart etc.) exposed would be authorised as usual by Oauth2.
The configurable (username,password) properties you can define in your local.properties.
<!-- Swagger UI security with basic auth -->
<http pattern="/v2/*swagger*/**" xmlns="http://www.springframework.org/schema/security"
authentication-manager-ref="basicAuthenticationManager">
<intercept-url pattern="/v2/*swagger*/**" access="isAuthenticated()" />
<http-basic />
<csrf />
</http>
<security:authentication-manager id="basicAuthenticationManager">
<security:authentication-provider>
<security:user-service>
<security:user
name="#{configurationService.configuration.getProperty('swagger.basicauth.username')}"
password="{noop}#{configurationService.configuration.getProperty('swagger.basicauth.password')}"
authorities="ROLE_USER" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
<!-- Commerce Webservices V2-->
<http pattern="/v2/**" entry-point-ref="oauthAuthenticationEntryPointV2"
#######existing configurations##########
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Experts,
After following the above link , able to get swagger Pop Up. But getting Cookie Expired Error. We are using spartacus .
screenshot-2023-10-10-at-15247-pm.png.
So, wanted to know how we can log into swagger by getting Authorized
Thanks in Advance.
Regards.
P.N.B.Srivatsa
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.