Navigation

    Hedgehack community

    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    When trying to authorize http, the response is always "status_code":401,"status":"Unauthorized"

    YCCaster
    2
    3
    341
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dmytro.hryn
      dmytro.hryn last edited by dmytro.hryn

      Hello assistant, I have developed an API for authorization using an http request. YcCaster and API are running in kubernetes on the same pod but in different containers. Config file looks like this:

      caster:
        host: yccaster-svil.good.cloud
        address: 0.0.0.0:2101
        identifier: My caster
        operator: My organization
        nmea: 1
        country: EST
        latitude: 59.44
        longitude: 24.74
        fallback_host: 0.0.0.0
        fallback_port: 0
        misc: Some notes
      configuration:
        auth:
        - type: file
          options:
            mount-points: conf/mountpoints.yml
            clients: conf/clients.yml
        - type: http
          options:
            url: http://127.0.0.1:8888/yc-caster-api/mountpoints/ntrip_auth
            secret: super_secret
        api:
          host: yccaster-svil.good.cloud
          address: 0.0.0.0:8080
          api-keys:
            - "very_goood_key"
        events:
          - type: file
            options:
              path: /var/caster/session.log
              types:
                - caster-ready
                - caster-terminate
                - connection-accepted
                - connection-terminated
                - ntrip-request-accepted
                - ntrip-request-rejected
                - ntrip-session-started
                - ntrip-session-ended
      license-key: ""
      

      when I try to connect the antenna, in the logs I get the response:

      {"name":"ntrip-request-rejected","timestamp":1689150511,"data":{"address":"130.211.2.114:51817","request":{"method":"SOURCE","password":"string","uri":"string","headers":[{"name
      ":"Source-Agent","value":"NTRIP RTKLIB/2.4.2"},{"name":"STR"}],"type":"server","ntrip_version":1,"connection_id":"dba2c3db-a31c-41e7-8fe1-81f2ea263847"},"response":{"-":"HTTP/1.
      0","status_code":401,"status":"Unauthorized"},"connection_id":"dba2c3db-a31c-41e7-8fe1-81f2ea263847"}}
      

      this is very strange because when I request from the same container using "curl", I get the correct response with the code "200" and in the body "description" :

      root@yc-caster-885b96fcb-nd5rc:/var/caster# curl -X POST -vvv -H "Content-Type: application/json" -H "X-Api-Key: super_secret" -d '{"method":"SOURCE","password":"string","uri":"
      string","http_version":"HTTP/1.0","headers":[{"name":"User-Agent","value":"NTRIP YCServer"}],"type":"server","ntrip_version":1
      }' http://127.0.0.1:8888/yc-caster-api/mountpoints/ntrip_auth
      Note: Unnecessary use of -X or --request, POST is already inferred.
      *   Trying 127.0.0.1:8888...
      * Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)
      > POST /yc-caster-api/mountpoints/ntrip_auth HTTP/1.1
      > Host: 127.0.0.1:8888
      > User-Agent: curl/7.81.0
      > Accept: */*
      > Content-Type: application/json
      > X-Api-Key: super_secret
      > Content-Length: 174
      >
      * Mark bundle as not supporting multiuse
      < HTTP/1.1 200 OK
      < Content-Type: application/json;charset=UTF-8
      < content-length: 331
      <
      * Connection #0 to host 127.0.0.1 left intact
      {"identifier":"string","format":"string","formatDetails":"string","carrier":"string","navSystem":"string","network":"string","country":"string","latitude":0.0,"longitude":0.0,"n
      mea":"string","solution":"string","generator":"string","comprEncryp":"string","authentication":"string","fee":"string","bitrate":"string","misc":"string"}root@yc-caster-885b96fc
      b-nd5rc:/var/caster#
      

      I can't figure out why the caster is getting "Unauthorized" when the request doesn't reach the API, any ideas how to solve this or how to debug it from the caster?

      1 Reply Last reply Reply Quote 0
      • ilyavialkov
        ilyavialkov last edited by

        @dmytro-hryn said in When trying to authorize http, the response is always "status_code":401,"status":"Unauthorized":

        auth:

        • type: file
          options:
          mount-points: conf/mountpoints.yml
          clients: conf/clients.yml
        • type: http
          options:
          url: http://127.0.0.1:8888/yc-caster-api/mountpoints/ntrip_auth
          secret: super_secret

        Remove file auth from config and keep only http.

        dmytro.hryn 1 Reply Last reply Reply Quote 0
        • dmytro.hryn
          dmytro.hryn @ilyavialkov last edited by dmytro.hryn

          @ilyavialkov I removed authentication through a file, but that didn't solve the problem:

          caster:
            host: yccaster-svil.sigemi.cloud
            address: 0.0.0.0:2101
            identifier: My caster
            operator: My organization
            nmea: 1
            country: EST
            latitude: 59.44
            longitude: 24.74
            fallback_host: 0.0.0.0
            fallback_port: 0
            misc: Some notes
          configuration:
            auth:
            - type: http
              options:
                url: http://127.0.0.1:8888/yc-caster-api/mountpoints/ntrip_auth
                secret: super_secret
            api:
              host: yccaster-svil.sigemi.cloud
              address: 0.0.0.0:8080
              api-keys:
                - "104ebb67-a4bq-4c20-we36-99cb759d1ee9"
            events:
              - type: file
                options:
                  path: /var/caster/session.log
                  types:
                    - caster-ready
                    - caster-terminate
                    - connection-accepted
                    - connection-terminated
                    - ntrip-request-accepted
                    - ntrip-request-rejected
                    - ntrip-session-started
                    - ntrip-session-ended
          license-key: ""
          

          and now in the logs there is no attempt to connect the source, only this:

          {"name":"caster-ready","timestamp":1689165626,"data":{"address":"[::]:2101","started_at":1689165626}}
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB | Contributors