Mendix API Basic Auth

0
Hello experts,   I am currently studying this module(https://academy.mendix.com/link/modules/529/lectures/4151/5.4-Typical-Authentication-Types) and was wondering what "The credentials are the username and password combined with a colon base64 encoded." means in this context.     It would be appreciated if you could explain it with examples.   Thank you.   Best regards
asked
2 answers
0

Hello Gain Lee,

 

Basic Authentication is an often used authentication method with API's it makes use of an username and password and this username and password are merged into the Authorization  header and base64 encoded. 

 

So for you understanding you can use for example postman to see what happens with this authentication method in your request.

 

image.pngEncoded is this:

image.png

 

Hope this clears it a bit,

 

Good luck!

 

answered
0

And this is what Chat GPT has to say about it:

 

In Basic Authentication, the process of encoding the credentials (username and password) involves the following steps:

  1. Combine the username and password: Join the username and password into a single string with a colon (:) between them. For example, if the username is user and the password is pass, you create the string

    makefile

    user:pass

  2. Base64 encode the combined string: Encode the resulting string from the first step using Base64 encoding. Base64 encoding is a way of converting binary data into an ASCII string format by translating it into a radix-64 representation. Using the user:pass example, the encoded string would be:

    dXNlcjpwYXNz

  3. Use the encoded string in the HTTP request: The Base64 encoded string is then used as part of the HTTP Authorization header. The header will look something like this:

    makefile

    Authorization: Basic dXNlcjpwYXNz

Example in Steps

Let's go through the example step by step:

  1. Combine username and password:

    makefile

    user:pass

  2. Base64 encode the combined string:

    dXNlcjpwYXNz

  3. Construct the HTTP Authorization header:

    makefile

    Authorization: Basic dXNlcjpwYXNz

When a client sends an HTTP request with this header, the server will decode the Base64 string to retrieve the original user:pass credentials and verify them.

Why Use Base64 Encoding?

  • Uniform Data Representation: Base64 encoding ensures that the credentials are represented in a standard ASCII string format, which can be easily included in HTTP headers.
  • Transmission Safety: Base64 encoding ensures that the credentials can be safely transmitted over protocols that may not support binary data.

Security Note

While Base64 encoding is used for encoding the credentials, it is not a secure encryption method. The encoded credentials can be easily decoded. Therefore, Basic Authentication should always be used over a secure HTTPS connection to prevent exposure of credentials.

answered