Skip to main content

Hello,
I have an API whose authentication is only done by user/password: basic authentication.
How can I translate this into the json file?
Knowing that I only want to provide the user and password, and not the base64 encoding of user/password in the header.

A clarification:
Curl example using the RedHat Satellite API:

curl -X GET -s -k -u sat_username:sat_password https://satellite6.example.com/api/v2/

response :

*   Trying 55.37.75.137...

* TCP_NODELAY set

* Connected to satellite-connected.cnamts.admtangers (55.37.75.137) port 443 (#0)

* ALPN, offering h2

* ALPN, offering http/1.1

* successfully set certificate verify locations:

*   CAfile: /etc/pki/tls/certs/ca-bundle.crt

  CApath: none

* TLSv1.3 (OUT), TLS handshake, Client hello (1):

* TLSv1.3 (IN), TLS handshake, Server hello (2):

* TLSv1.3 (IN), TLS handshake, ano content] (0):

* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):

* TLSv1.3 (IN), TLS handshake, ano content] (0):

* TLSv1.3 (IN), TLS handshake, Request CERT (13):

* TLSv1.3 (IN), TLS handshake, ano content] (0):

* TLSv1.3 (IN), TLS handshake, Certificate (11):

* TLSv1.3 (IN), TLS handshake, ano content] (0):

* TLSv1.3 (IN), TLS handshake, CERT verify (15):

* TLSv1.3 (IN), TLS handshake, ano content] (0):

* TLSv1.3 (IN), TLS handshake, Finished (20):

* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):

* TLSv1.3 (OUT), TLS handshake, ano content] (0):

* TLSv1.3 (OUT), TLS handshake, Certificate (11):

* TLSv1.3 (OUT), TLS handshake, ano content] (0):

* TLSv1.3 (OUT), TLS handshake, Finished (20):

* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384

* ALPN, server accepted to use h2

* Server certificate:

*  subject: C=FR; O=CNAM; OU=CNAM/DDSI/CSH DIJON; CN=satellite-connected.cnamts.admtangers

*  start date: Dec 23 13:23:54 2024 GMT

*  expire date: Dec 23 13:23:54 2027 GMT

*  subjectAltName: host "satellite-connected.cnamts.admtangers" matched cert's "satellite-connected.cnamts.admtangers"

*  issuer: C=FR; O=CNAM; OU=180035024; CN=AC CNAM SERVICES G2 HP

*  SSL certificate verify ok.

* Using HTTP2, server supports multi-use

* Connection state changed (HTTP/2 confirmed)

* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0

* TLSv1.3 (OUT), TLS app data, no content] (0):

* TLSv1.3 (OUT), TLS app data, no content] (0):

* TLSv1.3 (OUT), TLS app data, no content] (0):

* Server auth using Basic with user 'user_supervision'

* Using Stream ID: 1 (easy handle 0x558229163740)

* TLSv1.3 (OUT), TLS app data, no content] (0):

> GET /api/status HTTP/2

> Host: satellite-connected.cnamts.admtangers

> Authorization: Basic dXNlcl9zdXBlcnZpc2lvbjpNY1VBSG41UGxadjZ6a0JSYlRlc2ZR

> User-Agent: curl/7.61.1

> Accept: */*

>

* TLSv1.3 (IN), TLS handshake, hno content] (0):

* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):

* TLSv1.3 (IN), TLS handshake, hno content] (0):

* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):

* TLSv1.3 (IN), TLS app data, no content] (0):

* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!

* TLSv1.3 (OUT), TLS app data, no content] (0):

* TLSv1.3 (IN), TLS app data, no content] (0):

* TLSv1.3 (IN), TLS app data, no content] (0):

< HTTP/2 200

< foreman_version: 3.12.0.6

< foreman_api_version: 2

< foreman_current_organization: ; ANY

< foreman_current_location: ; ANY

< content-type: application/json; charset=utf-8

< apipie-checksum: 6654064c0ca429af5e8bfe2a706237ced7a6778b

< etag: W/"7f85e442417919efdb657ec4006c72cf"

< cache-control: max-age=0, private, must-revalidate

< x-request-id: d0252e57-34a1-452d-a795-991b78dcdb1d

< x-runtime: 0.204802

< strict-transport-security: max-age=631139040; includeSubdomains

< x-frame-options: sameorigin

< x-content-type-options: nosniff

< x-xss-protection: 1; mode=block

< x-download-options: noopen

< x-permitted-cross-domain-policies: none

< content-security-policy: default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data:; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'

< content-length: 94

< set-cookie: _session_id=46fb20933635f6c6b32ea7dac9b47f9c; path=/; secure; HttpOnly; SameSite=Lax

< via: 2.0 satellite-connected.cnamts.admtangers

< date: Thu, 17 Apr 2025 14:43:54 GMT

< server: Apache

<

* Connection #0 to host satellite-connected.cnamts.admtangers left intac
t

 

In json file, how can i build this header with:
Authorization: Basic dXNlcl9zdXBlcnZpc2lvbjpNY1VBSG41UGxadjZ6a0JSYlRlc2ZR
to the right of Basic we have a base64 of the string username:password

Thanks


Reply