Skip to content

Commit 5a17e73

Browse files
authored
Merge pull request #1 from iij/update-2023.03
Update 2023.03
2 parents 5bb9f43 + caf46a1 commit 5a17e73

37 files changed

+1690
-280
lines changed

build.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/bash
22
set -eu
33
export GO111MODULE=on
4-
export GOBIN=$(pwd)/bin
4+
OUT_DIR=$(pwd)/bin
55

6-
echo "GOBIN: ${GOBIN}"
6+
echo "output: ${OUT_DIR}"
7+
mkdir -p "${OUT_DIR}"
78
ls -1 src/ngx_auth/exec | while read d ; do
8-
echo -n "install ${d}: "
9+
echo -n "build ${d}: "
910
(
1011
cd "src/ngx_auth/exec/${d}" || exit 1
11-
go install -ldflags '-s -w' || exit
12+
go build -o "${OUT_DIR}" -ldflags '-s -w' || exit
1213
) || continue
1314
echo done
1415
done

conf/auth-header-path.conf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
socket_type = "tcp"
2-
socket_path = "127.0.0.1:9202"
2+
socket_path = "127.0.0.1:9200"
3+
#cache_seconds = 0
34
path_header = "X-Authz-Path"
45
user_header = "X-Forwarded-User"
56

67
[authz]
8+
user_map_config = "/etc/ngx_auth_mod/usermap_config.conf"
79
user_map = "/etc/ngx_auth_mod/usermap.conf"
810

911
path_pattern = "^/([^/]+)/"
10-
nomatch_right = "@admin"
11-
default_right = "*/
12+
nomatch_right = "*"
13+
default_right = "@admin"
1214

1315
[authz.path_right]
1416
"test" = "@dev"

conf/auth-ldap-path.conf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
socket_type = "tcp"
2-
socket_path = "127.0.0.1:9201"
2+
socket_path = "127.0.0.1:9200"
3+
#cache_seconds = 0
4+
#use_etag = false
35
auth_realm = "TEST Authentication"
46
path_header = "X-Authz-Path"
57

@@ -17,11 +19,12 @@ uniq_filter = "(&(objectCategory=person)(objectClass=user)(memberOf=CN=Group1,DC
1719
timeout = 5000
1820

1921
[authz]
22+
user_map_config = "/var/ngx_auth_mod/usermap_config.conf"
2023
user_map = "/etc/ngx_auth_mod/usermap.conf"
2124

2225
path_pattern = "^/([^/]+)/"
23-
nomatch_right = "@admin"
24-
default_right = "*"
26+
nomatch_right = "*"
27+
default_right = "@admin"
2528

2629
[authz.path_right]
2730
"test" = "@dev"

conf/auth-ldap-path2ldap.conf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
socket_type = "tcp"
2-
socket_path = "127.0.0.1:9203"
2+
socket_path = "127.0.0.1:9200"
3+
#cache_seconds = 0
4+
#use_etag = false
35
auth_realm = "TEST Authentication"
46
path_header = "X-Authz-Path"
57

@@ -17,7 +19,7 @@ uniq_filter = "(&(objectCategory=person)(objectClass=user)(userPrincipalName=%s@
1719
timeout = 5000
1820

1921
[authz]
20-
path_pattern = "^/([^/]+)/"
22+
path_pattern = "^/([^/]*)/"
2123
#ban_nomatch = false
2224
nomatch_filter = "" # for root directory files
2325
ban_default = true

conf/auth-ldap.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
socket_type = "tcp"
22
socket_path = "127.0.0.1:9200"
3+
#cache_seconds = 0
4+
#use_etag = false
35
auth_realm = "TEST Authentication"
46

57
host_url = "ldaps://ldap.example.com"

conf/auth-simple.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
socket_type = "tcp"
22
socket_path = "127.0.0.1:9200"
3+
#cache_seconds = 0
34
auth_realm = "TEST Authentication"
45

56
[password]

conf/usermap_config.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
user_regex = '^[A-Za-z_][0-9A-Za-z_\-]{0,32}$'
2+
group_regex = '^[A-Za-z_][0-9A-Za-z_\-]{0,32}$'

docs/check_ldap.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ check_ldap <config file> <user name>
1616

1717
Execute with the configuration file and user name as arguments.
1818
After execution, enter the password and the result will be output.
19-
20-
The configuration file is the same as [ngx\_ldap\_auth](ngx_ldap_auth.md).

docs/ngx_header_path_auth.md

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ See the [auth request module documentation](http://nginx.org/en/docs/http/ngx_ht
2323

2424
The **ngx\_header\_path\_auth** configuration file is in TOML format, and the following is a sample configuration file.
2525

26-
2726
```ini
2827
socket_type = "tcp"
2928
socket_path = "127.0.0.1:9202"
29+
#cache_seconds = 0
3030
path_header = "X-Authz-Path"
3131
user_header = "X-Forwarded-User"
3232

@@ -43,38 +43,51 @@ default_right = "*/
4343
4444
Each parameter of the configuration file is as follows.
4545
46-
* **socket\_type** - Set this parameter to tcp(TCP socket) or unix(UNIX domain socket).
47-
* **socket\_path** - Set the IP address and port number for tcp, and UNIX domain socket file path for unix.
48-
* **path\_header** - A HTTP header that sets the path used for authorization processing. The default value is `X-Authz-Path`. In the appropriate place of the nginx configuration file, use `proxy_set_header` directive to set the HTTP header. (Eg `proxy_set_header X-Authz-Path $request_uri;`)
49-
* **user\_header** - A HTTP header to set the user name. The default value is `X-Forwarded-User`. In the appropriate place of the nginx configuration file, use `proxy_set_header` directive to set the HTTP header. (Eg `proxy_set_header X-Forwarded-User $remote_user;`)
46+
### Root part
47+
48+
| Parameter | Description |
49+
| :--- | :--- |
50+
| **socket\_type** | Set this parameter to tcp(TCP socket) or unix(UNIX domain socket). |
51+
| **socket\_path** | Set the IP address and port number for tcp, and UNIX domain socket file path for unix. |
52+
| **cache\_seconds** | The cache duration in seconds to pass to nginx. However, if its value is 0, it will not use the cache.<br>See [Authentication Cache Control](proxy_cache.md) for details.|
53+
| **path\_header** | A HTTP header that sets the path used for authorization processing. The default value is `X-Authz-Path`. In the appropriate place of the nginx configuration file, use `proxy_set_header` directive to set the HTTP header. (Eg `proxy_set_header X-Authz-Path $request_uri;`) |
54+
| **user\_header** | A HTTP header to set the user name. The default value is `X-Forwarded-User`. In the appropriate place of the nginx configuration file, use `proxy_set_header` directive to set the HTTP header. (Eg `proxy_set_header X-Forwarded-User $remote_user;`) |
55+
56+
### **\[authz\]** part
5057
51-
* \[authz\] part
52-
* **user_map** - User name and group name mapping file. More on this in the "_**user\_map** file details_" section.
53-
* **path\_pattern** - A regular expression that extracts the authorization judgment string from the path of the header specified by **path_header**. The extracted string is used for the key in **path\_right**. Use the `()` subexpression regular expression only once to specify the extraction location.
54-
* **nomatch\_right** - Authorization rights when the **path\_pattern** regular expression is not matched. For more information on authorization rights, see "_Authorization rights details_" section.
55-
* **default\_right** - Authorization rights when it matches the **path\_pattern**の regular expression and is not specified in **path\_right**. For more information on authorization rights, see "_Authorization rights details_".
56-
* **path\_right** - Authorization rights map for each extracted string when matching **path\_pattern** regular expression. Specify the extraction string as the key. For more information on authorization rights, see "_Authorization rights details_" section.
58+
| Parameter | Description |
59+
| :--- | :--- |
60+
| **user\_map\_config** | A file that specifies how user names and group names are handled in **user\_map**. More on this in the "_**user\_map\_config** file details_" section. |
61+
| **user_map** | User name and group name mapping file. More on this in the "_**user\_map** file details_" section. |
62+
| **path\_pattern** | A regular expression that extracts the authorization judgment string from the path of the header specified by **path\_header**. The extracted string is used for the key in **path\_right**. Use the `()` subexpression regular expression only once to specify the extraction location. |
63+
| **nomatch\_right** | Authorization rights when the **path\_pattern** regular expression is not matched. For more information on authorization rights, see "_Authorization rights details_" section. |
64+
| **default\_right** | Authorization rights when it matches the **path\_pattern**の regular expression and is not specified in **path\_right**. For more information on authorization rights, see "_Authorization rights details_". |
65+
| **path\_right** | Authorization rights map for each extracted string when matching **path\_pattern** regular expression. Specify the extraction string as the key. For more information on authorization rights, see "_Authorization rights details_" section. |
5766
5867
## Authorization rights details
5968
60-
In \[authz\] part, **nomatch\_right**, **default\_right**, and **path\_right** table value specify a character string that combines the following judgment descriptions with `|`. The combined judgment process is calculated by logical disjunction("OR"). If the result is true, it is authorized.
69+
In **\[authz\]** part, **nomatch\_right**, **default\_right**, and **path\_right** table value specify a character string that combines the following judgment descriptions with `|`. The combined judgment process is calculated by logical disjunction("OR"). If the result is true, it is authorized.
6170
62-
* '' - (empty string) Always considers true regardless of the user name.
63-
* '!' - Always considers false regardless of the user name.
64-
* '*' - If the user name exists, it is considered true.
65-
* '@groupname` - The character string after @ is treated as a group name. True if the group contains users. Groups are defined in the **user_map** file.
66-
* '@' - (no group name) True if the user is described in the **user_map** file.
67-
* 'username` True if the user name matches.
71+
| Authorization method | Description|
72+
| :--- | :--- |
73+
| empty string | Always considers true regardless of the user name. |
74+
| `!` | Always considers false regardless of the user name. |
75+
| `*` | If the user name exists, it is considered true. |
76+
| `@groupname` | The character string after @ is treated as a group name. True if the group contains users. Groups are defined in the **user_map** file. |
77+
| `@` (no group name) | True if the user is described in the **user_map** file. |
78+
| user name | True if the user name matches. |
6879
69-
## **user\_map** file details
80+
## **user\_map\_config** file details
7081
71-
**user\_map** is a text file that defines users and groups.
72-
This text file defines a user-group mapping, with a user name and group names (None or more is possible) on each line, as shown below.
82+
**user\_map\_config** is a file that defines the handling of user names and group names.
83+
This text file defines the available usernames and group names in regular expressions, as shown below.
7384
74-
``` plaintext
75-
user1:group1 group2 ...
76-
...
85+
```
86+
user_regex = '^[a-z_][0-9a-z_\-]{0,32}$'
87+
group_regex = '^[a-z_][0-9a-z_\-]{0,32}$'
7788
```
7889
79-
Separate the user name and group name with `:`. If there are multiple group names, separate them with ` ` (space character).
80-
90+
| Parameter| Description|
91+
| :--- | :--- |
92+
| **user\_regex** | A regular expression of strings to allow as usernames. |
93+
| **group\_regex** | Regular expression of strings to allow as group names. |

docs/ngx_ldap_auth.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ On error, the process terminates with an unsuccessful status.
99
## How to start
1010

1111
Run it on the command line like this:
12-
12+
[ngx_header_path_auth](ngx_header_path_auth.md)
1313
```
1414
ngx_ldap_auth <config file>
1515
```
@@ -28,6 +28,8 @@ The **ngx\_ldap\_auth** configuration file is in TOML format, and the following
2828
```ini
2929
socket_type = "tcp"
3030
socket_path = "127.0.0.1:9200"
31+
#cache_seconds = 0
32+
#use_etag = true
3133
auth_realm = "TEST Authentication"
3234

3335
host_url = "ldaps://ldap.example.com"
@@ -45,14 +47,18 @@ timeout = 5000
4547

4648
Each parameter of the configuration file is as follows.
4749

48-
* **socket\_type** - Set this parameter to tcp(TCP socket) or unix(UNIX domain socket).
49-
* **socket\_path** - Set the IP address and port number for tcp, and UNIX domain socket file path for unix.
50-
* **auth\_realm** - HTTP realm string.
51-
* **host\_url** - The URL of the LDAP server connection address. The pass part is not used.
52-
* **start\_tls** - Set to 1 when using TLS STARTTLS.
53-
* **skip\_cert\_verify** - Set to 1 to ignore the certificate check result.
54-
* **root\_ca\_files** - A list of PEM files for the CA certificate. Used when the LDAP server is using a certificate from a private CA.
55-
* **base\_dn** - The base DN when connecting to the LDAP server.
56-
* **bind\_dn** - This is the bind DN when performing LDAP bind processing. Rewrite `%s` as the remote user name and `%%` as `%`.
57-
* **uniq\_filter** - Only if this value is set, search with this value filter. If the search result is one DN, the authentication will be successful.
58-
* **timeout** - Communication timeout(unit: ms) with the LDAP server.
50+
| Parameter | Description |
51+
| :--- | :--- |
52+
| **socket\_type** | Set this parameter to tcp(TCP socket) or unix(UNIX domain socket). |
53+
| **socket\_path** | Set the IP address and port number for tcp, and UNIX domain socket file path for unix. |
54+
| **cache\_seconds** | The cache duration in seconds to pass to nginx. However, if its value is 0, it will not use the cache.<br>See [Authentication Cache Control](proxy_cache.md) for details.|
55+
| **use_etag** | Set to `true` to enable cache validation using `ETag` tags.<br>See [Authentication Cache Control](proxy_cache.md) for details.|
56+
| **auth\_realm** | HTTP realm string. |
57+
| **host\_url** | The URL of the LDAP server connection address. The pass part is not used. |
58+
| **start\_tls** | Set to 1 when using TLS STARTTLS. |
59+
| **skip\_cert\_verify** | Set to 1 to ignore the certificate check result. |
60+
| **root\_ca\_files** | A list of PEM files for the CA certificate. Used when the LDAP server is using a certificate from a private CA. |
61+
| **base\_dn** | The base DN when connecting to the LDAP server. |
62+
| **bind\_dn** | This is the bind DN when performing LDAP bind processing. Rewrite `%s` as the remote user name and `%%` as `%`. |
63+
| **uniq\_filter** | Only if this value is set, search with this value filter. If the search result is one DN, the authentication will be successful. |
64+
| **timeout** | Communication timeout(unit: ms) with the LDAP server. |

0 commit comments

Comments
 (0)