You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/12/24 07:04:44 UTC

[GitHub] [pulsar-manager] yixing1337 opened a new pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

yixing1337 opened a new pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369


   Fixes #ISSUE-361
   
   ### Motivation
   Pulsar manager's swagger does not work, so I try to fix this issue.
   
   ### Modifications
   1. Swagger urls can't be accessed because the interceptors  blocked them, so I modified the interceptors to allow swagger urls.
   2. I added a swagger configration in `application.properties`, thus, if you want to use swagger in development environment, you can set the value `true`. And  if you don't want to enable swagger in production environment, you can set the value `false`.
   3. I modified the `SwaggerConfig` class, because swagger need some authorization infomation, otherwise it will receive 401 code in response header.
   4. I modified the README.md to show how to use swagger, and added some images in docs.
   5. Now the swagger can work correctly.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the `./gradlew build` checks.
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] abenbouz commented on pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
abenbouz commented on pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#issuecomment-847882723


   hello 
   i have tested last release 0.2.1 but i have an issue with pulsar manager swagger ui 
   when i access the url  http://backend:7750/swagger-ui.html  i have the flowing error  : 
   
   {"message":"Please login."}
   
   have any idea on how to solve that ?
   Thanks
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] yixing1337 commented on a change in pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
yixing1337 commented on a change in pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#discussion_r549578577



##########
File path: src/main/resources/application.properties
##########
@@ -153,3 +153,6 @@ tls.pulsar.admin.ca-certs=ca-client-path
 
 # support peek message, default false
 pulsar.peek.message=false
+
+# swagger configration
+swagger.enabled=true

Review comment:
       yes, good suggestion, I set this property false, and commit again




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] abenbouz commented on pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
abenbouz commented on pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#issuecomment-848624738


   in my environement i'm not able to compile from source so i'm using binaries and i have added swagger.enabled=true


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] Jennifer88huang commented on a change in pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
Jennifer88huang commented on a change in pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#discussion_r549545513



##########
File path: src/README.md
##########
@@ -187,6 +187,42 @@ Set the `bkvm.enabled` field to `true` in the file [bkvm.conf](https://github.co
         apachepulsar/pulsar-manager:v0.2.0
     ```
 
+### Enable swagger ui
+If you want to enable swagger ui, please set the following option to true in file `application.properties`, default value is true.
+if you don't want to enable swagger ui in production environment, you can set the value false.
+
+```$xslt
+swagger.enabled=true
+```
+
+### How to use swagger to access the API
+1. Please enable swagger ui 'swagger.enabled=true' in `application.properties`
+
+2. Visit http://YOUR_BACKEND_SERVICE_HOST:7750/swagger-ui.html
+
+3. If you directly try apis in swagger, you will receive a 401 response, because it has not been authorized.
+    So please request the login api first, use the username and password of the pulsar manager to login, 
+    and copy the `token` of the response header, next step will use the token.
+    The request body is like this:
+    ```$xslt
+    {
+      "username": "admin",
+      "password": "apachepulsar"
+    }
+    ```
+    Then copy the token of the response header
+    ![swagger-request-login](../docs/img/swagger-request-login.png)
+
+4. Click the `Authorize` button in swagger ui, and then fill in the authorize information of swagger
+     - environment: the environment name you configed in pulsar manager
+     - token: the token you copied above
+     - username: the username you just login
+    
+    ![swagger-authorize](../docs/img/swagger-authorize.png)
+
+5. Then you can directly request other apis and receive correct response, because it has been authorized.
+

Review comment:
       ```suggestion
   ### How to use swagger to access the API
   1. Enable swagger UI by setting 'swagger.enabled=true' in the `application.properties` file.
   
   2. Visit http://YOUR_BACKEND_SERVICE_HOST:7750/swagger-ui.html
   
   3. Request the login API, use the username and password of the Pulsar Manager to login, copy the `token` of the response header.
      
       The request body is as follows:
       ```$xslt
       {
         "username": "admin",
         "password": "apachepulsar"
       }
       ```
       Copy the token of the response header.
       ![swagger-request-login](../docs/img/swagger-request-login.png)
   
   4. Authorize. Click the `Authorize` button in swagger UI, and then fill in the authorization information of swagger.
        - environment: the environment name you have configured in Pulsar Manager.
        - token: the token you have copied in the previous step.
        - username: the username you login.
       
       ![swagger-authorize](../docs/img/swagger-authorize.png)
   
   5. Request other APIs.
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] abenbouz commented on pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
abenbouz commented on pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#issuecomment-848623553


   @ yixing1337  
   thanks for your answer 
   
   i have updated the application properties  :  swagger.enabled=true
   
   and then for the Readme i have the html message in the second step 
   
   2 - Visit http://YOUR_BACKEND_SERVICE_HOST:7750/swagger-ui.html  --> 
    {"message":"Please login."}
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] tuteng commented on a change in pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
tuteng commented on a change in pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#discussion_r549545895



##########
File path: src/main/resources/application.properties
##########
@@ -153,3 +153,6 @@ tls.pulsar.admin.ca-certs=ca-client-path
 
 # support peek message, default false
 pulsar.peek.message=false
+
+# swagger configration
+swagger.enabled=true

Review comment:
       I suggest we disabled it by default, many users will deploy it directly online, which may bring some security issues, if users want to enable it on, they can configure it themselves




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] yixing1337 commented on pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
yixing1337 commented on pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#issuecomment-848639076


   @abenbouz 
   Hi, You mentioned earlier that the release version you downloaded is v0.2.1, but the latest version is v0.2.0
   the v0.2.0 was released on 2020-09-28, but this pr was merged later on 2020-12-29.
   so if you want to use the swagger feature, you have to compile from the master branch.
   and what's problems did you have when you compile from the source? maybe I can help you to fix it.   :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] yixing1337 commented on pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
yixing1337 commented on pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#issuecomment-848546859


   @abenbouz
   Hi, I have tried again, and make sure the swagger works well.
   Did you config the `swagger.enabled=true` in application.properties?
   And then you can follow the steps of `Enable swagger UI` in pulsar-manager/src/README.md.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] Jennifer88huang commented on a change in pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
Jennifer88huang commented on a change in pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#discussion_r549543433



##########
File path: src/README.md
##########
@@ -187,6 +187,42 @@ Set the `bkvm.enabled` field to `true` in the file [bkvm.conf](https://github.co
         apachepulsar/pulsar-manager:v0.2.0
     ```
 
+### Enable swagger ui
+If you want to enable swagger ui, please set the following option to true in file `application.properties`, default value is true.
+if you don't want to enable swagger ui in production environment, you can set the value false.
+
+```$xslt
+swagger.enabled=true
+```

Review comment:
       ```suggestion
   ### Enable swagger UI
   To enable swagger UI, set `swagger.enabled=true` in the `application.properties` file. The default value is `true`.
   
   If you want to disable swagger UI in the  production environment, you can set `swagger.enabled=false`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] abenbouz commented on pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
abenbouz commented on pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369#issuecomment-848648717


   hi ,
   
   yes version 0.2.1 from stream native https://github.com/streamnative/pulsar-manager/releases/tag/v0.2.1
   
   this version includes your fix 
   
   for the compile it's an internal problem linked to internet access 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-manager] tuteng merged pull request #369: fix ISSUE-361: Pulsar manager's swagger dose not work.

Posted by GitBox <gi...@apache.org>.
tuteng merged pull request #369:
URL: https://github.com/apache/pulsar-manager/pull/369


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org