Skip to content
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

Got "Unauthorized" error when executing interval action with security enabled #4479

Closed
cherrycl opened this issue Mar 25, 2023 · 6 comments · Fixed by #4489
Closed

Got "Unauthorized" error when executing interval action with security enabled #4479

cherrycl opened this issue Mar 25, 2023 · 6 comments · Fixed by #4489
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cherrycl
Copy link
Contributor

🐞 Bug Report

Affected Services [REQUIRED]

The issue is located in: Scheduler

Is this a regression?

Yes

Description and Minimal Reproduction [REQUIRED]

  1. Deploy security EdgeX with compose file
  2. Create an Interval with following request body
POST https://localhost:8443/support-scheduler/api/v2/interval with JWT token
[
   {
      "interval":{
         "name":"interval_1679737508110",
         "start":"20230325T094508",
         "interval":"30s"
      },
      "apiVersion":"v2"
   }
]
  1. Create an Interval Action with the following request body
POST https://localhost:8443/support-scheduler/api/v2/intervalaction with JWT token
[
   {
      "action":{
         "name":"intervalAction_1679737508231",
         "intervalName":"interval_1679737508110",
         "address":{
            "type":"REST",
            "host":"edgex-core-data",
            "port":59880,
            "httpMethod":"DELETE",
            "path":"/api/v2/event/age/0"
         },
         "AdminState":"UNLOCKED"
      },
      "apiVersion":"v2"
   }
]
  1. Sleep 30 seconds

🔥 Exception or Error

Event didn't clean up and found the following error on support-scheduler logs.


level=ERROR ts=2023-03-25T09:51:38.341410182Z app=support-scheduler source=manager.go:154 msg="fail to send request with RESTAddress, err: request failed, status code: 401, err: Unauthorized\n"

🌍 Your Environment

Deployment Environment: Ubuntu / x86

EdgeX Version [REQUIRED]: Main

Anything else relevant?

@cherrycl cherrycl added the bug Something isn't working label Mar 25, 2023
@lenny-goodell lenny-goodell added this to the Minnesota milestone Mar 28, 2023
@bnevis-i
Copy link
Collaborator

You didn't specify the AuthMethod for the HTTP request. Try this:

POST https://localhost:8443/support-scheduler/api/v2/intervalaction with JWT token
[
   {
      "action":{
         "name":"intervalAction_1679737508231",
         "intervalName":"interval_1679737508110",
         "address":{
            "type":"REST",
            "host":"edgex-core-data",
            "port":59880,
            "httpMethod":"DELETE",
            "path":"/api/v2/event/age/0"
         },
         "AdminState":"UNLOCKED",
         "AuthMethod":"JWT"
      },
      "apiVersion":"v2"
   }
]

If it still fails with the above, then there is a problem.

@cloudxxx8
Copy link
Member

@bnevis-i support-scheduler currently doesn't support the REST call with JWT authentication. Are you going to fix it or I can assign my team member to work on it?

@lenny-goodell
Copy link
Member

@cloudxxx8 , it was added here: #4419

@lenny-goodell
Copy link
Member

@bnevis-i , the documentation here needs to be updated for the changes in this PR.
https://docs.edgexfoundry.org/3.0/microservices/support/scheduler/Ch-Scheduler/#data-dictionary
Diagrams also??

@cherrycl
Copy link
Contributor Author

@bnevis-i After adding the AuthMethod, the error was not found. Thank you

@bnevis-i
Copy link
Collaborator

bnevis-i commented Apr 3, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants