Use HTTP authentication
- Last Updated: March 19, 2024
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
OpenEdge.Net library enables you to pass security
credentials through one of the following authentication mechanisms:- HTTP basic authentication
- HTTP digest authentication
- Authentication callback
- On-demand authentication
In all of these mechanisms, you only need to create and pass credentials
to the appropriate authentication method when building an HTTP request. Any required
encryption or encoding is done automatically by the OpenEdge.Net procedure library.
HTTP basic authentication
In HTTP basic authentication, the HTTP client passes credentials preemptively in an Authorization header along with the request. Because this authentication method passes credentials preemptively, it is useful only when you know the user's credentials in advance and when you are sure that the server requires credentials to process the request.Note that credentials are encoded using the Base64 encoding scheme, but not encrypted, so this mechanism is secure only when you are using HTTPS.
To implement HTTP basic
authentication, create a Credentials object and
pass it to the UsingBasicAuthentication() method.
The Credentials class constructor takes three
parameters: domain, username, and password.
|
HTTP digest authentication
In HTTP digest authentication, the HTTP client creates a hash key by encrypting certain fields, such as username and password, using a nonce (a random number generated for one-time use) provided by the server. The client then sends the hash key back to the server. The server produces its own hash key from the same fields (username, password, etc) and compares it with the hash key that is sent by the HTTP client. If the hash keys match, the authentication succeeds and the server provides access to the requested resource.HTTP digest is more secure than HTTP basic authentication.
Credentials object and
pass it to a UsingDigestAuthentication() method
when building an HTTP request. Other steps, such as obtaining a nonce from the
server and creating a hash key, are performed internally by the OpenEdge.Net library.
|
Authentication callback
In the authentication callback mechanism, the HTTP client responds to a server's demand for authentication by invoking an ABL class or procedure that is responsible for providing the required credentials (typically through a login form or widget presented to a user).To implement the
authentication callback mechanism, use the AuthCallback() method as shown in the following examples.
Adding Auth Filter Callback as a class
|
Adding Auth Filter Callback as a procedure
|
On-demand authentication
This method is similar to HTTP basic authentication; however, instead of sending credentials preemptively, the HTTP client sends credentials only when required by the server. To implement this authentication mechanism, use theUsingCredentials() method as shown
in the following example.
|
Authorization header
In addition to using any of the authentication mechanisms listed in this topic, you can use theAddHeader() method to specify the Authorization
header. This is useful in certain situations, such as when you need to pass OAuth bearer
tokens.
|