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

authHeader is null when use API key #848

Open
Farmhouse-Admin opened this issue Jan 29, 2025 · 0 comments
Open

authHeader is null when use API key #848

Farmhouse-Admin opened this issue Jan 29, 2025 · 0 comments
Assignees
Labels
needs-triage Needs triage
Milestone

Comments

@Farmhouse-Admin
Copy link

When try to use API key for POST data gives error "authHeader" is null. But can use API key with GET requests. DB2Rest version Version 1.4.1

auth.yml

name: db2rest-security

resourceRoles:

  • resource: "/v1/rdbms/db/inventory_SunVending/**"
    method: post
    roles:

    • role1
  • resource: "/v1/rdbms/db//v1/rdbms/db/inventory_SunVending"
    method: get
    roles:

    • role1

excludedResources:

  • resource: "/v1/rdbms/**"
    method: get
  • resource: "/v1/rdbms/**"
    method: put
  • resource: "/v1/rdbms/**"
    method: delete

apiKeys:

  • key: 'Authkey1'
    roles: [role1]
    active: true

POST

curl --request POST --url http://192.168.5.103:8080/v1/rdbms/db/inventory_SunVending --header 'X-API-KEY: Authkey1' --header 'Content-Type: application/json' --header 'User-Agent: insomnia/8.6.1' --data '{ "machine_id": "32372", "location_name": "VX0-7000100006-D1103-(รพ.รามาธิบดี อาคารพระเทพฯชั้น2)", "product_code": "123368", "product_name": "H.D. สตรอเบอร์รี่ลูกเกด", "max_quantity": "7", "remaining_amount": "5", "refill_quantity": "2", "remaining_products": "71.42857142857143 %", "product_price": "13", "sold_price": "12", "date": "17-01-2025 00:01:02" }'
{"type":"https://db2rest.com/error/generic-error","title":"Generic Data Access Error","status":400,"detail":"Database ID not found.","instance":"/error","errorCategory":"Data-access-error","timestamp":"2025-01-29T08:32:57.821874536Z"}

Error

ERROR 6255 --- [omcat-handler-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

java.lang.NullPointerException: Cannot invoke "String.substring(int)" because "authHeader" is null
at com.homihq.db2rest.auth.basic.BasicAuthProvider.authenticate(BasicAuthProvider.java:36) ~[auth-1.4.1.jar!/:1.4.1]
at com.homihq.db2rest.auth.AuthFilter.doFilterInternal(AuthFilter.java:46) ~[auth-1.4.1.jar!/:1.4.1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.14.jar!/:6.1.14]

GET

curl --request GET --url http://192.168.5.103:8080/v1/rdbms/db/inventory_SunVending?filter=date=gt=16-01-2025 --header 'Accept-Profile: ' --header 'User-Agent: insomnia/8.4.5' --header 'X-API-KEY: Authkey1'

Results as expected.

@kdhrubo kdhrubo added the needs-triage Needs triage label Jan 29, 2025
@kdhrubo kdhrubo added this to the Jan2025 milestone Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Needs triage
Projects
None yet
Development

No branches or pull requests

3 participants