Skip to content

Commit e394e7f

Browse files
authored
Merge pull request #6274 from KD23243/protectAppsGatewayDocs
Add identity gateway integration tutorials for the Asgardeo docs
2 parents 12f3762 + 26ffa87 commit e394e7f

13 files changed

Lines changed: 721 additions & 0 deletions
3.12 MB
Loading
3.43 MB
Loading
584 KB
Loading
3.11 MB
Loading
560 KB
Loading
3.3 MB
Loading
575 KB
Loading
382 KB
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use {{product_name}} with identity gateways
2+
3+
An identity gateway sits in front of your application and enforces authentication and authorization before requests reach your application.
4+
5+
Identity gateways protect your application by,
6+
7+
- intercepting incoming traffic.
8+
9+
- verifying the user’s identity (using protocols like OAuth2 or OpenID Connect).
10+
11+
- enforcing fine-grained access rules.
12+
13+
- forwarding the request to the application only if it meets the security requirements.
14+
15+
By connecting {{product_name}} with identity gateways, you can centralize user management and apply consistent access control across your entire application ecosystem.
16+
17+
![Identity gateway architecture showing the flow between client, identity gateway, {{product_name}}, and protected applications]({{base_path}}/assets/img/tutorials/protect-apps-with-identity-gateway/identity_gateway_architecture.png)
18+
19+
This section explains how to connect {{product_name}} with the following identity gateways.
20+
21+
- [OAuth2 Proxy]({{base_path}}/references/tutorials/protect-apps-with-identity-gateway/protect-apps-with-oauth2proxy/)
22+
23+
- [Oathkeeper]({{base_path}}/references/tutorials/protect-apps-with-identity-gateway/protect-apps-with-oathkeeper/)
24+
25+
- [Mod Auth OpenIDC]({{base_path}}/references/tutorials/protect-apps-with-identity-gateway/protect-apps-with-mod-auth-openidc/)
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
# Integrate Mod Auth OpenIDC with {{product_name}}
2+
3+
[Mod Auth OpenIDC](https://github.com/zmartzone/mod_auth_openidc){: target="_blank"} is an Apache HTTP Server module that provides OpenID Connect authentication. It acts as a reverse proxy that authenticates users via an external OIDC provider (like {{product_name}}) and forwards identity information to your back-end app via HTTP headers. This guide explains how you can connect {{product_name}} with Mod Auth OpenIDC.
4+
5+
![Mod Auth OpenIDC flow diagram showing authentication flow between client, Apache with Mod Auth OpenIDC, {{product_name}}, and back-end application]({{base_path}}/assets/img/tutorials/protect-apps-with-identity-gateway/mod_auth_openidc_architecture.png)
6+
7+
## Prerequisites
8+
9+
- A {{product_name}} organization. If you don't have one, [create a free account]({{base_path}}/get-started/create-asgardeo-account/).
10+
11+
- A package manager (for example apt, yum, Homebrew) to install Apache HTTPD.
12+
13+
- An application with a back-end. If you don't have one, you can use this [sample application](https://github.com/wso2/samples-is/raw/refs/heads/master/identity-gateway/sample-request-logger-app/request-logger.jar){: target="_blank"}.
14+
15+
## Step 1: Register an OIDC application
16+
17+
To connect your Mod Auth OpenIDC Apache HTTPD module to {{product_name}}, you need to register it as an application. To do so,
18+
19+
1. Sign in to the [{{product_name}} Console](https://console.asgardeo.io/){: target="_blank"} and go to your organization.
20+
21+
2. [Register a Traditional Web Application]({{base_path}}/guides/applications/register-oidc-web-app/) with the **OpenID Connect** protocol and the following details:
22+
23+
- **Name** - mod-auth-app
24+
- **Authorized redirect URL** - The URL where {{product_name}} sends the authentication response after login. For example: `http://localhost:8002/oauth2/callback` (or your proxy callback URL).
25+
26+
3. Take note of the **Client ID** and **Client Secret** [generated for your application]({{base_path}}/guides/applications/register-oidc-web-app/#get-the-client-id-and-secret).
27+
28+
## Step 2: (Optional) Set up sample application
29+
30+
If you have your own application, you can skip this step. If you want to use the sample Java application, follow the steps below to set it up.
31+
32+
1. Download the [sample application](https://github.com/wso2/samples-is/raw/refs/heads/master/identity-gateway/sample-request-logger-app/request-logger.jar){: target="_blank"}.
33+
34+
2. Use the following command to run the application.
35+
36+
```java
37+
cd path/to/app/folder
38+
java -jar request-logger.jar
39+
```
40+
41+
3. Go to `http://localhost:8080` and verify that the application works.
42+
43+
![Sample app running showing the application startup and running status]({{base_path}}/assets/img/tutorials/protect-apps-with-identity-gateway/sample-app-running.png)
44+
45+
## Step 3: Install Apache and Mod Auth OpenIDC
46+
47+
Follow the steps below to install Apache httpd and the required dependencies.
48+
49+
!!! note
50+
51+
The commands below assume a macOS environment. Use the corresponding package manager in your environment for installations. To learn more, refer to the [Apache httpd documentation](https://httpd.apache.org/docs/2.4/install.html){: target="_blank"}.
52+
53+
1. Install Apache httpd if you don't have it already.
54+
55+
```sh
56+
brew install httpd
57+
```
58+
59+
2. Install the following dependencies required by Mod Auth OpenIDC.
60+
61+
```sh
62+
brew install jansson cjose libcurl
63+
```
64+
65+
3. Clone and build Mod Auth OpenIDC.
66+
67+
```sh
68+
git clone https://github.com/zmartzone/mod_auth_openidc.git
69+
cd mod_auth_openidc
70+
./autogen.sh
71+
./configure --with-apxs=$(which apxs)
72+
make
73+
make install
74+
```
75+
76+
!!! tip "Troubleshoot build errors"
77+
78+
Homebrew may install dependencies in non-standard locations, which can cause the installation to fail.
79+
80+
If the `./configure --with-apxs=$(which apxs)` command fails, try specifying the exact paths to the dependencies:
81+
82+
```sh
83+
./configure --with-apxs2=/opt/homebrew/bin/apxs \
84+
--with-openssl=/opt/homebrew/opt/openssl@3 \
85+
--with-jansson=/opt/homebrew/opt/jansson \
86+
--with-cjose=/opt/homebrew/opt/cjose
87+
make
88+
make install
89+
```
90+
91+
After building, the .so module should appear in `/opt/homebrew/lib/httpd/modules/mod_auth_openidc.so`.
92+
93+
## Step 4: Configure Apache to use Mod Auth OpenIDC with {{product_name}}
94+
95+
The following steps explain how to configure Mod Auth OpenIDC to act as a reverse proxy and authenticate users via {{product_name}}.
96+
97+
1. Open your Apache configuration file at `/opt/homebrew/etc/httpd/httpd.conf` and add the following line to load the Mod Auth OpenIDC module
98+
99+
```apache
100+
LoadModule auth_openidc_module /path/to/mod_auth_openidc.so
101+
```
102+
103+
!!! tip
104+
Load this module only once to avoid conflicts.
105+
106+
2. Create a new file at `/opt/homebrew/etc/httpd/extra/httpd-oidc.conf` and add the following content. This file will contain the VirtualHost configuration for OIDC authentication.
107+
108+
```apache
109+
Listen 8002
110+
<VirtualHost *:8002>
111+
ServerName localhost
112+
113+
OIDCCryptoPassphrase a-random-secret-value
114+
115+
OIDCProviderMetadataURL https://api.asgardeo.io/t/<organization_name>/oauth2/token/.well-known/openid-configuration
116+
117+
OIDCClientID YOUR_CLIENT_ID
118+
OIDCClientSecret YOUR_CLIENT_SECRET
119+
OIDCRedirectURI http://localhost:8002/callback
120+
121+
OIDCRemoteUserClaim sub
122+
OIDCSSLValidateServer On
123+
124+
ProxyPass / http://localhost:8080/
125+
ProxyPassReverse / http://localhost:8080/
126+
127+
<Location />
128+
AuthType openid-connect
129+
Require valid-user
130+
</Location>
131+
</VirtualHost>
132+
```
133+
134+
!!! note
135+
136+
- Replace `<organization_name>` with the name of your {{product_name}} organization.
137+
138+
- Replace `YOUR_CLIENT_ID` and `YOUR_CLIENT_SECRET` with the client ID and the client secret you received earlier when registering the application in {{product_name}}.
139+
140+
- This sample configuration file assumes that the following services run on the specified endpoints. If your setup differs, adjust the configuration accordingly.
141+
- {{product_name}}: `https://api.asgardeo.io/t/<organization_name>`
142+
- Apache with Mod Auth OpenIDC: `http://localhost:8002`
143+
- Back-end Service (API or Web application): `http://localhost:8080`
144+
145+
3. Open the Apache configuration file at `/opt/homebrew/etc/httpd/httpd.conf` and include the following line to include the VirtualHost configuration file you created above.
146+
147+
```apache
148+
Include /opt/homebrew/etc/httpd/extra/httpd-oidc.conf
149+
```
150+
151+
4. Start Apache.
152+
153+
```sh
154+
sudo apachectl restart
155+
```
156+
157+
## Try it out
158+
159+
Now that you’ve set up {{product_name}}, the sample application (or your own), and Mod Auth OpenIDC Apache HTTPD module, follow the steps below to test them in action.
160+
161+
1. Log in to your app through the Apache server by visiting `http://localhost:8002`. You will be redirected to the login page of {{product_name}}.
162+
163+
2. Log in with an existing user.
164+
165+
3. After successfully logging in, the Mod Auth OpenIDC module automatically injects OIDC claims into HTTP headers for your back-end application. You can access user information through headers like:
166+
167+
- `OIDC_CLAIM_sub`: User identifier
168+
- `OIDC_CLAIM_org_name`: Organization name
169+
- `OIDC_access_token`: Access token
170+
- `OIDC_id_token`: ID token
171+
172+
![Mod Auth OpenIDC logged in showing successful authentication and user information]({{base_path}}/assets/img/tutorials/protect-apps-with-identity-gateway/mod_auth_openidc_logged_in.png)
173+
174+
!!! tip
175+
176+
Include these configurations in your `httpd-oidc.conf` VirtualHost file to control which claims Mod Auth OpenIDC forwards to the application.
177+
178+
```apache
179+
OIDCRemoteUserClaim sub
180+
OIDCClaimPrefix "OIDC_CLAIM_"
181+
OIDCClaimDelimiter "_"
182+
```
183+
184+
Learn more about these configurations in the [Apache documentation](https://github.com/OpenIDC/mod_auth_openidc/blob/master/auth_openidc.conf){: target="_blank"}.
185+
186+
## Advanced configurations
187+
188+
You can enhance the integration between {{product_name}} and Mod Auth OpenIDC with the following advanced options.
189+
190+
### Encrypt connections with TLS
191+
192+
To encrypt communication between clients and Mod Auth OpenIDC, you can enable TLS. To do so, add the following to your `httpd-oidc.conf` VirtualHost configuration file:
193+
194+
```apache
195+
<VirtualHost *:443>
196+
SSLEngine on
197+
SSLCertificateFile /path/to/cert.pem
198+
SSLCertificateKeyFile /path/to/cert.key
199+
200+
# ... rest of your OIDC configurations
201+
</VirtualHost>
202+
```
203+
204+
### Configure sessions handling
205+
206+
To manage user sessions for Mod Auth OpenIDC, add the following directives to your `httpd-oidc.conf` VirtualHost configuration:
207+
208+
```apache
209+
OIDCSessionInactivityTimeout 3600
210+
OIDCSessionMaxDuration 86400
211+
OIDCCookieHTTPOnly On
212+
OIDCCookieSecure Off # Set to On for production HTTPS
213+
```
214+
215+
Learn more about these configurations in the [Apache documentation](https://github.com/OpenIDC/mod_auth_openidc/blob/master/auth_openidc.conf){: target="_blank"}.
216+
217+
---
218+
219+
Now that you’ve successfully connected {{product_name}} with Mod Auth OpenIDC module, you can leverage this integration to:
220+
221+
- Add authentication to applications that lack native OIDC support.
222+
223+
- Replace custom or insecure authentication methods.
224+
225+
- Centralize and simplify authentication logic.
226+
227+
This setup secures dashboards, microservices, and legacy apps, improving stack security, scalability, and maintainability.

0 commit comments

Comments
 (0)