|
| 1 | +# OIDC config for ocserv |
| 2 | + |
| 3 | +The following is an example of how to configure ocserv to use OpenID Connect |
| 4 | + |
| 5 | +Pre-built binary of ocserv does not include OpenID Connect support. You will need to build ocserv by yourself. |
| 6 | + |
| 7 | +The README is based on official documentation from the ocserv project. The official documentation can be found at [https://gitlab.com/openconnect/ocserv](https://gitlab.com/openconnect/ocserv) |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +- Debian / Ubuntu |
| 12 | + |
| 13 | + ```bash |
| 14 | + # Required |
| 15 | + apt-get install -y libgnutls28-dev libev-dev |
| 16 | + # Optional functionality and testing |
| 17 | + apt-get install -y libpam0g-dev liblz4-dev libseccomp-dev \ |
| 18 | + libreadline-dev libnl-route-3-dev libkrb5-dev libradcli-dev \ |
| 19 | + libcurl4-gnutls-dev libcjose-dev libjansson-dev liboath-dev \ |
| 20 | + libprotobuf-c-dev libtalloc-dev libhttp-parser-dev protobuf-c-compiler \ |
| 21 | + gperf iperf3 lcov libuid-wrapper libpam-wrapper libnss-wrapper \ |
| 22 | + libsocket-wrapper gss-ntlmssp haproxy iputils-ping freeradius \ |
| 23 | + gawk gnutls-bin iproute2 yajl-tools tcpdump |
| 24 | + ``` |
| 25 | + |
| 26 | +- Fedora / RHEL |
| 27 | + |
| 28 | + ```bash |
| 29 | + # Required |
| 30 | + yum install -y gnutls-devel libev-devel |
| 31 | + # Optional functionality and testing |
| 32 | + yum install -y pam-devel lz4-devel libseccomp-devel readline-devel \ |
| 33 | + libnl3-devel krb5-devel radcli-devel libcurl-devel cjose-devel \ |
| 34 | + jansson-devel liboath-devel protobuf-c-devel libtalloc-devel \ |
| 35 | + http-parser-devel protobuf-c gperf iperf3 lcov uid_wrapper \ |
| 36 | + pam_wrapper nss_wrapper socket_wrapper gssntlmssp haproxy iputils \ |
| 37 | + freeradius gawk gnutls-utils iproute yajl tcpdump |
| 38 | + ``` |
| 39 | + |
| 40 | +## Build ocserv with OpenID Connect support |
| 41 | + |
| 42 | +In order to use OIDC with ocserv, you will need to build ocserv with the `--enable-oidc-auth` option. This option is not enabled by default. |
| 43 | + |
| 44 | +- clone the ocserv repository `git clone https://gitlab.com/openconnect/ocserv` |
| 45 | + |
| 46 | +- generate the configure script `./autogen.sh` |
| 47 | + |
| 48 | +- generate ocserv Makefile with OIDC support `./configure --enable-oidc-auth` |
| 49 | + |
| 50 | +- build ocserv `make` |
| 51 | + |
| 52 | +## Prepare the OIDC configuration |
| 53 | + |
| 54 | +The following doc is based on the official OIDC config doc from the ocserv project. The official documentation can be found at [https://gitlab.com/openconnect/ocserv/-/blob/master/doc/README-oidc.md](https://gitlab.com/openconnect/ocserv/-/blob/master/doc/README-oidc.md) |
| 55 | + |
| 56 | +- Prepare OIDC configuration under `/etc/ocserv/conf/oidc.json` |
| 57 | + |
| 58 | + ```json |
| 59 | + { |
| 60 | + "openid_configuration_url": "<uri of openid-configuration doc>", |
| 61 | + "user_name_claim": "preferred_username", |
| 62 | + "required_claims": { |
| 63 | + "aud": "SomeAudience, should be the client_id from the OIDC provider", |
| 64 | + "iss": "SomeIssuer, should be the issuer URL from the OIDC provider" |
| 65 | + } |
| 66 | + } |
| 67 | + ``` |
| 68 | + |
| 69 | +- Edit `/etc/ocserv/ocserv.conf` to include the OIDC configuration. |
| 70 | + |
| 71 | + Do not forget to comment out any other `auth` configuration since only one `auth` method can be used at a time. |
| 72 | + |
| 73 | + ```conf |
| 74 | + auth = "oidc[config=/etc/ocserv/conf/oidc.json]" |
| 75 | + ``` |
| 76 | + |
| 77 | +- Start ocserv using the binary built in the previous step |
| 78 | + |
| 79 | + ```bash |
| 80 | + ocserv -c /etc/ocserv/ocserv.conf |
| 81 | + ``` |
0 commit comments