---
name: "Ns_Auth"
section: "3"
platform: "linux"
package: "aolserver4"
version: "4.0.10-7"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_Auth"
---

# Ns\_Auth(3)

URL level HTTP authorization support

```

```

## NAME

Ns\_AuthorizeRequest, Ns\_AuthorizeUser, Ns\_SetRequestAuthorizeProc, Ns\_SetUserAuthorizeProc - URL level HTTP authorization support

## SYNOPSIS

```
#include "ns.h"

int
Ns_AuthorizeRequest(char *server, char *method, char *url,
        char *user, char *passwd, char *peer)

int
Ns_AuthorizeUser(char *user, char *passwd)

void
Ns_SetRequestAuthorizeProc(char *server, Ns_RequestAuthorizeProc *procPtr)

void
Ns_SetUserAuthorizeProc(Ns_UserAuthorizeProc *procPtr)
```

## DESCRIPTION

These functions provide a means to create and use your own authorization mechanisms. They are used by the nsperm module to provide authentication and authorization of users to specific URLs.

You can define your own authorization functions. For example, you might create functions that will authorize a user by their SSL client certificate and if that fails, then attempt to authorize the user by username and password.

- **Ns\_AuthorizeRequest**(*server, method, url,*

          *user, passwd, peer*)

  Used to call the function registered by **Ns\_SetRequestAuthorizeProc** to authorize a user's access to the given method and URL. Possible return values are:

-

  NS\_OK - The user's access is authorized

-

  NS\_UNAUTHORIZED - Access is not public for this method or URL and either the user and password were not verified or the user does not have permission.

-

  NS\_FORBIDDEN - There is no possible user/password combination that would give authorization.

-

  NS\_ERROR - The authentication function could not perform the permission check.

- **Ns\_AuthorizeUser**(*user, passwd*)

  Checks that the cleartext password is correct for the specified user. Returns NS\_OK if it matches or NS\_ERROR if it does not match or if no authorization procedure is registered.

- **Ns\_SetRequestAuthorizeProc**(*server, procPtr*)

  Register the URL request authorization function. This function is called by **Ns\_AuthorizeRequest** and should return one of the four values give above for **Ns\_AuthorizeRequest**.

- **Ns\_SetUserAuthorizeProc**(*procPtr*)

  Register the user authorization function. This function is called by **Ns\_AuthorizeUser** and should return either NS\_OK or NS\_ERROR.

## SEE ALSO

nsd(1), [info(n)](/info/n.md)

## KEYWORDS
