tfHttpdUserAuthConfig

Jump to: navigation, search

Table of Contents >> Application Reference >> Web Server


#include <trsocket.h>


int tfHttpdUserAuthConfig (
ttHttpdUserSrvHandle userSrvHandle,
const char * objNamePtr,
const char * realmPtr,
const char * userNamePtr,
const char * passwordPtr,
int authType
);


Function Description

This function allows users to add/change or remove the access authentication for a certain file or directory and its sub-directories. Multiple authentication configurations are supported. When a page is requested, the configuration that best matches the requested URL is applied. For example You could protect "/cgi-bin" with realm "cgi" and "/cgi-bin/tcp" with realm "tcp". When "/cgi-bin/tcp/local" is requested, realm "tcp" is applied, and when /cgi-bin/device is requested, realm "cgi" is applied. When called with authType = TM_HTTPD_AUTH_NONE, you need to provide only objNamePtr. The authentication entry will be removed if it exists, if no entry exists for objNamePtr, TM_ENOENT will be returned. When called with the other two values for authType, an entry will be created if entry exists for objNamePtr, otherwise, the existing entry will be updated.

Two configuration macros exist to reduce the Treck code size, if needed. Basic and Digest authentication are supported, by default. Uncomment one or both of the following configuration macros in your trsystem.h to remove support. Use of an unsupported authType will return an error.

#define TM_DISABLE_HTTPD_BASIC_AUTH
#define TM_DISABLE_HTTPD_DIGEST_AUTH


Parameters

  • userSrvHandle
    Web server handle returned by tfHttpdUserStart()
  • objNamePtr
    Pointer to a directory or file, must start with '/', for example, "/", "/cgi-bin", "/index.html".
  • realmPtr
    Pointer to realm string
  • userNamePtr
    Pointer to username string
  • passwordPtr
    Pointer to password string
  • authType
TM_HTTPD_AUTH_BAA
Basic Access Authentication
TM_HTTPD_AUTH_DAA
Digest Access Authentication
TM_HTTPD_AUTH_NONE
To remove a existing authentication entry


Returns

  • TM_ENOERROR
    Success
  • TM_EINVAL
    Invalid userSrvHandle or NULL pointer for objNamePtr, realmPtr, userNamePtr, or passwordPtr, or authType is unknown.
  • TM_ENOENT
    Entry to be removed does not exist


Table of Contents >> Application Reference >> Web Server