├── autogen.sh ├── m4 ├── .gitignore └── ax_code_coverage.m4 ├── src ├── .gitignore ├── mod_oauth2.h └── mod_oauth2.c ├── .clang-format ├── AUTHORS ├── .gitignore ├── .project ├── Makefile.am ├── .github └── workflows │ └── build.yml ├── configure.ac ├── SECURITY.md ├── ChangeLog ├── README.md ├── LICENSE ├── oauth2.conf └── .cproject /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | autoreconf --force --install 3 | rm -rf autom4te.cache/ 4 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | /libtool.m4 2 | /ltoptions.m4 3 | /ltsugar.m4 4 | /ltversion.m4 5 | /lt~obsolete.m4 6 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | /*.la 2 | /*.lo 3 | /*.o 4 | /*.slo 5 | /.libs/ 6 | /.deps/ 7 | /.dirstamp 8 | /config.h 9 | /config.h.in 10 | /config.h.in~ 11 | /stamp-h1 12 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | IndentWidth: 8 3 | UseTab: Always 4 | BreakBeforeBraces: Linux 5 | AllowShortIfStatementsOnASingleLine: false 6 | IndentCaseLabels: false 7 | AllowShortFunctionsOnASingleLine: None 8 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The primary author of mod_oauth2 is: 2 | 3 | Hans Zandbelt 4 | 5 | Thanks to the following people for contributing to mod_oauth2 by 6 | reporting bugs, providing fixes, suggesting useful features or other: 7 | 8 | Jonathan Hurd 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /config.log 2 | /config.status 3 | /configure 4 | /Makefile 5 | /aclocal.m4 6 | /Makefile.in 7 | /libtool 8 | /ltmain.sh 9 | /missing 10 | /compile 11 | /config.guess 12 | /config.sub 13 | /depcomp 14 | /install-sh 15 | /.autotools 16 | /build/ 17 | /.settings/ 18 | /.libs/ 19 | /mod_oauth2.la 20 | /config.guess~ 21 | /config.sub~ 22 | /configure~ 23 | /install-sh~ 24 | -------------------------------------------------------------------------------- /src/mod_oauth2.h: -------------------------------------------------------------------------------- 1 | #ifndef _MOD_OAUTH2_H_ 2 | #define _MOD_OAUTH2_H_ 3 | 4 | /*************************************************************************** 5 | * 6 | * Copyright (C) 2018-2024 - ZmartZone Holding BV 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * @Author: Hans Zandbelt - hans.zandbelt@openidc.com 21 | * 22 | **************************************************************************/ 23 | 24 | #define OAUTH2_AUTH_TYPE "oauth2" 25 | #define OAUTH2_AUTH_TYPE_OPENIDC "auth-openidc" 26 | 27 | #endif /* _MOD_OAUTH2_H_ */ 28 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mod_oauth2 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.autotools.core.genmakebuilderV2 10 | 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 15 | clean,full,incremental, 16 | 17 | 18 | 19 | 20 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 21 | full,incremental, 22 | 23 | 24 | 25 | 26 | 27 | org.eclipse.cdt.core.cnature 28 | org.eclipse.cdt.core.ccnature 29 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 31 | org.eclipse.cdt.autotools.core.autotoolsNatureV2 32 | 33 | 34 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS=-I m4 2 | 3 | EXTRA_DIST = autogen.sh ChangeLog README.md LICENSE oauth2.conf 4 | 5 | AM_CPPFLAGS = -Wall -Werror 6 | AM_CPPFLAGS += -DOAUTH2_PACKAGE_NAME_VERSION=\"@PACKAGE_NAME@-@PACKAGE_VERSION@\" 7 | AM_CPPFLAGS += $(CODE_COVERAGE_CPPFLAGS) $(CODE_COVERAGE_CFLAGS) 8 | AM_LDFLAGS = --coverage 9 | 10 | LDADD = $(CODE_COVERAGE_LIBS) 11 | 12 | includesubdir = $(includedir)/oauth2 13 | 14 | includesub_HEADERS = \ 15 | src/mod_oauth2.h 16 | 17 | lib_LTLIBRARIES = @PACKAGE_NAME@.la 18 | 19 | @PACKAGE_NAME@_la_CFLAGS = @OAUTH2_CFLAGS@ @OAUTH2_APACHE_CFLAGS@ @APACHE_CFLAGS@ 20 | @PACKAGE_NAME@_la_LIBADD = @OAUTH2_LIBS@ @OAUTH2_APACHE_LIBS@ @APR_LIBS@ 21 | @PACKAGE_NAME@_la_SOURCES = src/@PACKAGE_NAME@.c 22 | @PACKAGE_NAME@_la_LDFLAGS = -module 23 | 24 | @CODE_COVERAGE_RULES@ 25 | 26 | clang-format: 27 | clang-format -style=file -i `find . -name *.[ch]` 28 | 29 | install: 30 | ${INSTALL} -d $(DESTDIR)$(shell @APXS@ @APXS_OPTS@ -q LIBEXECDIR) 31 | ${INSTALL} -p -m 755 .libs/@PACKAGE_NAME@.so $(DESTDIR)$(shell @APXS@ @APXS_OPTS@ -q LIBEXECDIR)/@PACKAGE_NAME@.so 32 | 33 | uninstall: 34 | rm -f $(DESTDIR)$(shell @APXS@ @APXS_OPTS@ -q LIBEXECDIR)/@PACKAGE_NAME@.so 35 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-22.04 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | 12 | - name: Dependencies 13 | run: | 14 | sudo apt-get update -y 15 | sudo apt-get install -y libssl-dev libcurl4-openssl-dev libhiredis-dev libmemcached-dev 16 | sudo apt-get install -y libjansson-dev libcjose-dev apache2-dev pkg-config 17 | cd /tmp 18 | #curl https://api.github.com/repos/OpenIDC/liboauth2/releases/latest | grep "browser_download_url.*liboauth2_.*jammy_amd64.deb" | cut -d: -f2,3 | tr -d \" | wget -qi - 19 | #curl https://api.github.com/repos/OpenIDC/liboauth2/releases/latest | grep "browser_download_url.*liboauth2-apache_.*jammy_amd64.deb" | cut -d: -f2,3 | tr -d \" | wget -qi - 20 | #curl https://api.github.com/repos/OpenIDC/liboauth2/releases/latest | grep "browser_download_url.*liboauth2-dev_.*jammy_amd64.deb" | cut -d: -f2,3 | tr -d \" | wget -qi - 21 | #sudo apt-get -y install ./*.deb 22 | git clone https://github.com/OpenIDC/liboauth2.git 23 | cd liboauth2 24 | ./autogen.sh 25 | ./configure 26 | make 27 | sudo make install 28 | - name: Configure 29 | run: | 30 | ./autogen.sh 31 | ./configure 32 | 33 | - name: Make 34 | run: make 35 | 36 | - name: Distcheck 37 | run: make distcheck DESTDIR="/tmp/mod_oauth2" 38 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([mod_oauth2],[4.0.0],[hans.zandbelt@openidc.com]) 2 | 3 | AM_INIT_AUTOMAKE([foreign no-define subdir-objects]) 4 | AC_CONFIG_MACRO_DIRS([m4]) 5 | 6 | LT_INIT([dlopen]) 7 | AC_PROG_CC 8 | 9 | AX_CODE_COVERAGE 10 | 11 | AC_ARG_WITH([apache], AS_HELP_STRING([--with-apache], [build with Apache support [default=autodetect]]),) 12 | AC_ARG_WITH([apxs], 13 | [AS_HELP_STRING([--with-apxs=PATH/NAME],[path to the apxs binary for Apache [[apxs]]])], 14 | [AC_SUBST(APXS, $with_apxs)], 15 | [AC_PATH_PROGS(APXS, [apxs2 apxs])]) 16 | if test "x$with_apache" != "xno"; then 17 | PKG_CHECK_MODULES([APR], [apr-1, apr-util-1], [have_apache="yes"], [have_apache="no"]) 18 | 19 | AS_IF([test "x${APXS}" != "x" -a -x "${APXS}"], 20 | [AC_MSG_NOTICE([apxs found at $APXS])], 21 | [AC_MSG_FAILURE(["apxs not found. Use --with-apxs"])]) 22 | 23 | APACHE_CFLAGS="`${APXS} -q CFLAGS` `${APXS} -q EXTRA_CPPFLAGS` -I`${APXS} -q INCLUDEDIR` ${APR_CFLAGS}" 24 | fi 25 | AM_CONDITIONAL(HAVE_APACHE, [test x"$have_apache" = "xyes"]) 26 | AC_SUBST(APR_LIBS) 27 | AC_SUBST(APACHE_CFLAGS) 28 | AC_ARG_VAR(APXS_OPTS, [additional command line options to pass to apxs]) 29 | 30 | PKG_CHECK_MODULES(OAUTH2, [liboauth2 >= 2.0.0]) 31 | AC_SUBST(OAUTH2_CFLAGS) 32 | AC_SUBST(OAUTH2_LIBS) 33 | 34 | PKG_CHECK_MODULES(OAUTH2_APACHE, [liboauth2_apache >= 2.0.0]) 35 | AC_SUBST(OAUTH2_APACHE_CFLAGS) 36 | AC_SUBST(OAUTH2_APACHE_LIBS) 37 | 38 | # Create Makefile from Makefile.in 39 | AC_CONFIG_FILES([ 40 | Makefile 41 | ]) 42 | AC_OUTPUT 43 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 3.3.x | :white_check_mark: | 8 | | < 3.3.0 | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | Please send an e-mail to support@openidc.com with a description of: 13 | 14 | - a brief description of the vulnerability 15 | - how the vulnerability can be observed 16 | - optionally the type of vulnerability and any related OWASP category 17 | - non-destructive exploitation details 18 | 19 | ## Followup 20 | After submitting your vulnerability report, you will receive an acknowledgement reply usually within 24 working hours of your report being received. 21 | 22 | The team will triage the reported vulnerability, and respond as soon as possible to let you know whether further information is required, whether the vulnerability is in or out of scope, or is a duplicate report. Priority for bug fixes or mitigations is assessed by looking at the impact severity and exploit complexity. 23 | 24 | When the reported vulnerability is resolved, or remediation work is scheduled, the Support team will notify you, and invite you to confirm that the solution covers the vulnerability adequately. 25 | 26 | You are particularly invited to give us feedback on the disclosure handling process, the clarity and quality of the communication relationship, and of course the effectiveness of the vulnerability resolution. This feedback will be used in strict confidence to help us improve our processes for handling reports, developing services, and resolving vulnerabilities. 27 | 28 | Where a report qualifies, we will offer to include you on our thanks and acknowledgement page. We will ask you to confirm the details you want included before they are published. 29 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 08/22/2024 2 | - change LICENSE to Apache 2.0 3 | - depend on liboauth2 >= 2.0.0 4 | - release 4.0.0 5 | 6 | 06/05/2024 7 | - depend on liboauth2 >= 1.6.2 8 | - release 3.4.0 9 | 10 | 10/25/2023 11 | - correct documentation wrt. cache encryption passphrase; see #52; thanks @webermax 12 | - depend on liboauth2 >= 1.5.1; see https://github.com/OpenIDC/liboauth2/issues/44 13 | 14 | 03/08/2023 15 | - move repo to OpenIDC github organization 16 | 17 | 01/21/2023 18 | - clean WWW-Authenticate header in main request as well if this is a subrequest; closes #42 19 | this avoids the WWW-Authenticate header to be sent in HTTP 200 responses; thanks @ErmakovDmitriy 20 | - depend on liboauth2 1.4.5.3 21 | - release 3.3.1 22 | 23 | 12/06/2022 24 | - change Makefile install procedure 25 | - depend on liboauth2 1.4.5.2 26 | - release 3.3.0 27 | 28 | 07/27/2022 29 | - depend on liboauth2 1.4.5 with multi-treading fix for "OAuth2TokenVerify jwk " 30 | - release 3.2.3 31 | 32 | 07/01/2021 33 | - change configure.ac to find Apache flags correctly 34 | 35 | 06/07/2021 36 | - depend on liboauth2 1.4.2.1 with fixed iat slack validation defaults 37 | - set WWW-Authenticate environment variable to allow for complex Require logic; see 38 | https://github.com/zmartzone/mod_auth_openidc/discussions/572 39 | example: 40 | Header always append WWW-Authenticate %{OAUTH2_BEARER_SCOPE_ERROR}e "expr=(%{REQUEST_STATUS} == 401) && (-n reqenv('OAUTH2_BEARER_SCOPE_ERROR'))" 41 | - release 3.2.2 42 | 43 | 02/01/2021 44 | - depend on liboauth2 1.4.1 with support for RFC 8705 mTLS Client Certificate bound access tokens 45 | - release 3.2.1 46 | 47 | 12/22/2020 48 | - depend on liboauth2 1.4.0 49 | - release 3.2.0 50 | 51 | 11/13/2020 52 | - add OAuth2CryptoPassphrase 53 | 54 | 11/10/2020 55 | - allow setting a cache with OAuth2Cache 56 | 57 | 11/07/2020 58 | - change Require keyword from "claim" to "oauth2_claim" to avoid interference with mod_auth_openidc 59 | - depend on liboauth2 >= 1.4.0 with new oauth2_token_verify (dpop) interface 60 | - bump to 3.2.0-dev 61 | 62 | 09/12/2019 63 | - depend on liboauth2 1.2.0 with new request header API 64 | - bump to 3.1.0 65 | 66 | 07/04/2019 67 | - depend on liboauth2 1.1.1 with log encapsulation changes 68 | - bump to 3.0.2 69 | 70 | 05/20/2019 71 | - add Apache Require claim authorization functions 72 | - bump to 3.0.1 73 | 74 | 03/22/2019 75 | - initial import of version 3.0.0 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://github.com/OpenIDC/mod_oauth2/actions/workflows/build.yml/badge.svg)](https://github.com/OpenIDC/mod_oauth2/actions/workflows/build.yml) 2 | 3 | # mod_oauth2 4 | 5 | A module for Apache HTTP Server 2.x that makes the Apache web server operate as a OAuth 2.0 Resource Server, 6 | validating OAuth 2.0 access tokens and setting headers/environment variables based on the validation results. 7 | 8 | 9 | ## Quickstart 10 | 11 | Reference Bearer Access Token validation using RFC7662 based introspection: 12 | ```apache 13 | AuthType oauth2 14 | OAuth2TokenVerify introspect https://pingfed:9031/as/introspect.oauth2 introspect.ssl_verify=false&introspect.auth=client_secret_basic&client_id=rs0&client_secret=2Federate 15 | ``` 16 | 17 | JWT Bearer Access Token validation using a set of JWKs published on a `jwks_uri`: 18 | ```apache 19 | AuthType oauth2 20 | OAuth2TokenVerify jwks_uri https://pingfed:9031/ext/one jwks_uri.ssl_verify=false 21 | ``` 22 | 23 | RFC 8705 Mutual TLS Certificate (optionally) Bound JWT Access Token validation with a known JWK 24 | ```apache 25 | AuthType oauth2 26 | OAuth2TokenVerify jwk "{\"kty\":\"RSA\",\"kid\":\"one\",\"use\":\"sig\",\"n\":\"12SBWV_4xU8sBEC2IXcakiDe3IrrUcnIHexfyHG11Kw-EsrZvOy6PrrcqfTr1GcecyWFzQvUr61DWESrZWq96vd08_iTIWIny8pU5dlCoC7FsHU_onUQI1m4gQ3jNr00KhH878vrBVdr_T-zuOYQQOBRMEyFG-I4nb91zO1n2gcpQHeabJw3JIC9g65FCpu8DSw8uXQ1hVfGUDZAK6iwncNZ1uqN4HhRGNevFXT7KVG0cNS8S3oF4AhHafFurheVxh714R2EseTVD_FfLn2QTlCss_73YIJjzn047yKmAx5a9zuun6FKiISnMupGnHShwVoaS695rDmFvj7mvDppMQ\",\"e\":\"AQAB\" }" type=mtls&mtls.policy=optional 27 | SSLVerifyClient optional_no_ca 28 | ``` 29 | 30 | RFC 9449 OAuth 2.0 Demonstrating Proof of Possession (DPoP) validation using introspection (using liboauth > 1.5.2) 31 | ```apache 32 | OAuth2TokenVerify introspect https://pingfed:9031/as/introspect.oauth2 introspect.ssl_verify=false&introspect.auth=client_secret_basic&client_id=rs_client&client_secret=2Federate&type=dpop 33 | ``` 34 | 35 | For a detailed overview of configuration options see the `oauth2.conf` Apache configuration file in this directory. 36 | 37 | ## Features 38 | 39 | As provided by the [`liboauth2`](https://github.com/OpenIDC/liboauth2) dependency, including: 40 | - per-directory configuration over per-virtual host 41 | - flexible cache configuration per cached element type 42 | - specify multiple token verification options, tried sequentially (allow for key/algo rollover) 43 | - claims-based authorization capabilities see: https://github.com/OpenIDC/mod_oauth2/wiki#authorization 44 | - etc. 45 | 46 | 47 | ## Support 48 | 49 | #### Community Support 50 | For generic questions, see the Wiki pages with Frequently Asked Questions at: 51 | [https://github.com/OpenIDC/mod_oauth2/wiki](https://github.com/OpenIDC/mod_oauth2/wiki) 52 | Any questions/issues should go to issues tracker. 53 | 54 | #### Commercial Services 55 | For commercial Support contracts, Professional Services, Training and use-case specific support you can contact: 56 | [sales@openidc.com](mailto:sales@openidc.com) 57 | 58 | 59 | Disclaimer 60 | ---------- 61 | *This software is open sourced by OpenIDC. For commercial support 62 | you can contact [OpenIDC](https://www.openidc.com) as described above in the [Support](#support) section.* 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | -------------------------------------------------------------------------------- /src/mod_oauth2.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * 3 | * Copyright (C) 2018-2024 - ZmartZone Holding BV 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | * @Author: Hans Zandbelt - hans.zandbelt@openidc.com 18 | * 19 | **************************************************************************/ 20 | 21 | #include "mod_oauth2.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | 39 | OAUTH2_APACHE_LOG(oauth2) 40 | 41 | // TODO: move the type into liboauth and use the Apache macro's (as in mod_sts)? 42 | typedef struct oauth2_cfg_dir_t { 43 | oauth2_cfg_source_token_t *source_token; 44 | oauth2_cfg_token_verify_t *verify; 45 | oauth2_cfg_target_pass_t *target_pass; 46 | } oauth2_cfg_dir_t; 47 | 48 | static apr_status_t oauth2_cfg_dir_cleanup(void *data) 49 | { 50 | oauth2_cfg_dir_t *cfg = (oauth2_cfg_dir_t *)data; 51 | oauth2_cfg_source_token_free(NULL, cfg->source_token); 52 | if (cfg->verify) 53 | oauth2_cfg_token_verify_free(NULL, cfg->verify); 54 | oauth2_cfg_target_pass_free(NULL, cfg->target_pass); 55 | oauth2_mem_free(cfg); 56 | return APR_SUCCESS; 57 | } 58 | 59 | static void *oauth2_cfg_dir_create(apr_pool_t *pool, char *path) 60 | { 61 | oauth2_cfg_dir_t *cfg = oauth2_mem_alloc(sizeof(oauth2_cfg_dir_t)); 62 | cfg->source_token = oauth2_cfg_source_token_init(NULL); 63 | cfg->verify = NULL; 64 | cfg->target_pass = oauth2_cfg_target_pass_init(NULL); 65 | apr_pool_cleanup_register(pool, cfg, oauth2_cfg_dir_cleanup, 66 | oauth2_cfg_dir_cleanup); 67 | return cfg; 68 | } 69 | 70 | static void *oauth2_cfg_dir_merge(apr_pool_t *pool, void *b, void *a) 71 | { 72 | oauth2_cfg_dir_t *cfg = oauth2_cfg_dir_create(pool, NULL); 73 | oauth2_cfg_dir_t *base = b; 74 | oauth2_cfg_dir_t *add = a; 75 | oauth2_cfg_source_token_merge(NULL, cfg->source_token, 76 | base->source_token, add->source_token); 77 | cfg->verify = add->verify 78 | ? oauth2_cfg_token_verify_clone(NULL, add->verify) 79 | : oauth2_cfg_token_verify_clone(NULL, base->verify); 80 | oauth2_cfg_target_pass_merge(NULL, cfg->target_pass, base->target_pass, 81 | add->target_pass); 82 | return cfg; 83 | } 84 | 85 | #define OAUTH2_REQUEST_STATE_KEY_CLAIMS "C" 86 | 87 | static int oauth2_request_handler(oauth2_cfg_source_token_t *cfg, 88 | oauth2_cfg_token_verify_t *verify, 89 | oauth2_cfg_target_pass_t *target_pass, 90 | oauth2_apache_request_ctx_t *ctx, 91 | bool error_if_no_token_found) 92 | { 93 | int rv = DECLINED; 94 | json_t *json_token = NULL; 95 | char *source_token = NULL; 96 | 97 | oauth2_debug(ctx->log, "enter"); 98 | 99 | oauth2_apache_scrub_headers(ctx, target_pass); 100 | 101 | source_token = oauth2_get_source_token( 102 | ctx->log, cfg, ctx->request, &oauth2_apache_server_callback_funcs, 103 | ctx->r); 104 | if (source_token == NULL) { 105 | if (error_if_no_token_found) { 106 | rv = oauth2_apache_return_www_authenticate( 107 | cfg, ctx, HTTP_UNAUTHORIZED, 108 | OAUTH2_ERROR_INVALID_REQUEST, 109 | "No bearer token found in the request."); 110 | } 111 | goto end; 112 | } 113 | 114 | if (oauth2_token_verify(ctx->log, ctx->request, verify, source_token, 115 | &json_token) == false) { 116 | rv = oauth2_apache_return_www_authenticate( 117 | cfg, ctx, HTTP_UNAUTHORIZED, OAUTH2_ERROR_INVALID_TOKEN, 118 | "Token could not be verified."); 119 | goto end; 120 | } 121 | 122 | if (oauth2_apache_set_request_user(target_pass, ctx, json_token) == 123 | false) { 124 | rv = oauth2_apache_return_www_authenticate( 125 | cfg, ctx, HTTP_UNAUTHORIZED, OAUTH2_ERROR_INVALID_TOKEN, 126 | "Could not determine remote user."); 127 | goto end; 128 | } 129 | 130 | oauth2_apache_request_state_set_json( 131 | ctx, OAUTH2_REQUEST_STATE_KEY_CLAIMS, json_token); 132 | oauth2_apache_target_pass(ctx, target_pass, source_token, json_token); 133 | 134 | rv = OK; 135 | 136 | end: 137 | 138 | if (source_token) 139 | oauth2_mem_free(source_token); 140 | if (json_token) 141 | json_decref(json_token); 142 | 143 | oauth2_debug(ctx->log, "leave"); 144 | 145 | return rv; 146 | } 147 | 148 | static int oauth2_check_user_id_handler(request_rec *r) 149 | { 150 | oauth2_cfg_dir_t *cfg = NULL; 151 | oauth2_apache_request_ctx_t *ctx = NULL; 152 | 153 | if (ap_auth_type(r) == NULL) 154 | return DECLINED; 155 | 156 | if (ap_is_initial_req(r) == 0) { 157 | 158 | if (r->main != NULL) 159 | r->user = r->main->user; 160 | else if (r->prev != NULL) 161 | r->user = r->prev->user; 162 | 163 | if (r->user != NULL) { 164 | 165 | ap_log_rerror( 166 | APLOG_MARK, APLOG_DEBUG, 0, r, 167 | "recycling user '%s' from initial request " 168 | "for sub-request", 169 | r->user); 170 | 171 | return OK; 172 | } 173 | } 174 | 175 | cfg = ap_get_module_config(r->per_dir_config, &oauth2_module); 176 | ctx = OAUTH2_APACHE_REQUEST_CTX(r, oauth2); 177 | 178 | oauth2_debug(ctx->log, 179 | "incoming request: \"%s?%s\" ap_is_initial_req=%d", 180 | r->parsed_uri.path, r->args, ap_is_initial_req(r)); 181 | 182 | if (strcasecmp((const char *)ap_auth_type(r), OAUTH2_AUTH_TYPE) == 0) 183 | return oauth2_request_handler(cfg->source_token, cfg->verify, 184 | cfg->target_pass, ctx, true); 185 | 186 | if (strcasecmp((const char *)ap_auth_type(r), 187 | OAUTH2_AUTH_TYPE_OPENIDC) == 0) 188 | return oauth2_request_handler(cfg->source_token, cfg->verify, 189 | cfg->target_pass, ctx, false); 190 | 191 | return DECLINED; 192 | } 193 | 194 | #define OAUTH2_BEARER_SCOPE_ERROR "OAUTH2_BEARER_SCOPE_ERROR" 195 | 196 | static authz_status 197 | oauth2_authz_checker(request_rec *r, const char *require_args, 198 | const void *parsed_require_args, 199 | oauth2_apache_authz_match_claim_fn_type match_claim_fn) 200 | { 201 | json_t *claims = NULL; 202 | oauth2_cfg_dir_t *cfg = NULL; 203 | oauth2_apache_request_ctx_t *ctx = NULL; 204 | authz_status rc = AUTHZ_DENIED_NO_USER; 205 | const char *value = NULL; 206 | 207 | cfg = ap_get_module_config(r->per_dir_config, &oauth2_module); 208 | ctx = OAUTH2_APACHE_REQUEST_CTX(r, oauth2); 209 | 210 | oauth2_debug(ctx->log, "enter"); 211 | 212 | if (r->user != NULL && strlen(r->user) == 0) 213 | r->user = NULL; 214 | 215 | oauth2_apache_request_state_get_json( 216 | ctx, OAUTH2_REQUEST_STATE_KEY_CLAIMS, &claims); 217 | 218 | rc = oauth2_apache_authorize(ctx, claims, require_args, match_claim_fn); 219 | if (claims) 220 | json_decref(claims); 221 | 222 | if ((rc == AUTHZ_DENIED) && ap_auth_type(r)) { 223 | oauth2_apache_return_www_authenticate( 224 | cfg->source_token, ctx, HTTP_UNAUTHORIZED, 225 | OAUTH2_ERROR_INSUFFICIENT_SCOPE, 226 | "Different scope(s) or other claims required."); 227 | value = apr_table_get(r->err_headers_out, 228 | OAUTH2_HTTP_HDR_WWW_AUTHENTICATE); 229 | apr_table_unset(r->err_headers_out, 230 | OAUTH2_HTTP_HDR_WWW_AUTHENTICATE); 231 | if (r->main) 232 | apr_table_unset(r->main->err_headers_out, 233 | OAUTH2_HTTP_HDR_WWW_AUTHENTICATE); 234 | oauth2_debug(ctx->log, 235 | "setting environment variable %s to \"%s\" for " 236 | "usage in mod_headers", 237 | OAUTH2_BEARER_SCOPE_ERROR, value); 238 | apr_table_set(r->subprocess_env, OAUTH2_BEARER_SCOPE_ERROR, 239 | value); 240 | } 241 | 242 | oauth2_debug(ctx->log, "leave"); 243 | 244 | return rc; 245 | } 246 | 247 | static authz_status oauth2_authz_checker_claim(request_rec *r, 248 | const char *require_args, 249 | const void *parsed_require_args) 250 | { 251 | return oauth2_authz_checker(r, require_args, parsed_require_args, 252 | oauth2_apache_authz_match_claim); 253 | } 254 | 255 | static const authz_provider oauth2_authz_claim_provider = { 256 | &oauth2_authz_checker_claim, NULL}; 257 | 258 | #define OAUTH2_REQUIRE_OAUTH2_CLAIM "oauth2_claim" 259 | 260 | OAUTH2_APACHE_HANDLERS(oauth2) 261 | 262 | static void oauth2_register_hooks(apr_pool_t *p) 263 | { 264 | ap_hook_post_config(OAUTH2_APACHE_POST_CONFIG(oauth2), NULL, NULL, 265 | APR_HOOK_MIDDLE); 266 | 267 | static const char *const aszPre[] = {"mod_ssl.c", NULL}; 268 | static const char *const aszSucc[] = {"mod_auth_openidc.c", NULL}; 269 | ap_hook_check_authn(oauth2_check_user_id_handler, aszPre, aszSucc, 270 | APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_CONF); 271 | 272 | ap_register_auth_provider( 273 | p, AUTHZ_PROVIDER_GROUP, OAUTH2_REQUIRE_OAUTH2_CLAIM, "0", 274 | &oauth2_authz_claim_provider, AP_AUTH_INTERNAL_PER_CONF); 275 | 276 | // TODO: register content handler for "special" stuff like returning the 277 | // JWKs that 278 | // the peer may use to encrypt the token and the private key 279 | // material that we use to sign e.g. client authentication 280 | // assertions 281 | // ap_hook_handler(oauth2_content_handler, NULL, NULL, APR_HOOK_MIDDLE); 282 | } 283 | 284 | OAUTH2_APACHE_CMD_ARGS1(oauth2, oauth2_cfg_dir_t, passphrase, 285 | oauth2_crypto_passphrase_set, NULL) 286 | OAUTH2_APACHE_CMD_ARGS2(oauth2, oauth2_cfg_dir_t, cache, oauth2_cfg_set_cache, 287 | NULL) 288 | OAUTH2_APACHE_CMD_ARGS3(oauth2, oauth2_cfg_dir_t, token_verify, 289 | oauth2_cfg_token_verify_add_options, &cfg->verify) 290 | OAUTH2_APACHE_CMD_ARGS2(oauth2, oauth2_cfg_dir_t, accept_token_in, 291 | oauth2_cfg_source_token_set_accept_in, 292 | cfg->source_token) 293 | OAUTH2_APACHE_CMD_ARGS1(oauth2, oauth2_cfg_dir_t, target_pass, 294 | oauth2_cfg_set_target_pass_options, cfg->target_pass) 295 | 296 | // clang-format off 297 | 298 | static const command_rec OAUTH2_APACHE_COMMANDS(oauth2)[] = { 299 | 300 | OAUTH2_APACHE_CMD_ARGS(oauth2, 1, 301 | "OAuth2CryptoPassphrase", 302 | passphrase, 303 | "Set crypto passphrase."), 304 | 305 | OAUTH2_APACHE_CMD_ARGS(oauth2, 23, 306 | "OAuth2TokenVerify", 307 | token_verify, 308 | "Set token verification method and options."), 309 | 310 | OAUTH2_APACHE_CMD_ARGS(oauth2, 12, 311 | "OAuth2AcceptTokenIn", 312 | accept_token_in, 313 | "Configures in which format source tokens can be presented."), 314 | 315 | OAUTH2_APACHE_CMD_ARGS(oauth2, 1, 316 | "OAuth2TargetPass", 317 | target_pass, 318 | "Configures in which format claims are passed to the target application."), 319 | 320 | OAUTH2_APACHE_CMD_ARGS(oauth2, 12, 321 | "OAuth2Cache", 322 | cache, 323 | "Set cache backend and options."), 324 | 325 | { NULL } 326 | }; 327 | 328 | OAUTH2_APACHE_MODULE_DECLARE_EX( 329 | oauth2, 330 | oauth2_cfg_dir_create, 331 | oauth2_cfg_dir_merge 332 | ) 333 | // clang-format on 334 | -------------------------------------------------------------------------------- /oauth2.conf: -------------------------------------------------------------------------------- 1 | # (Mandatory) 2 | # 3 | # Set AuthType 4 | #AuthType oauth2 5 | 6 | 7 | 8 | # (Optional) 9 | # 10 | # Configures a symmetric encryption key for cache values. 11 | # When not defined, the passphrase will be auto-generated which means it does not survive restarts. 12 | # 13 | #OAuth2CryptoPassphrase 14 | 15 | # 16 | # (Optional) 17 | # 18 | # Configures a cache. 19 | # Note that this directive must be defined before any OAuth2TokenVerify directive that uses it. 20 | # 21 | # type shm|file|redis|memcache cache backend type for access token validation results, default is shm 22 | # options cache backend specific options in query encoded format, see Cache Options 23 | # e.g name=myname&password=mypassword&encrypt=false 24 | # 25 | #OAuth2Cache [] 26 | # 27 | # 28 | # OAuth2Cache Options: 29 | # 30 | # (default) 31 | # 32 | # generic: 33 | # 34 | # name (default) the name of the (named) cache to refer to from e.g. OAuth2TokenVerify 35 | # key_hash_algo (sha256) hash algorithm for the cache key (or "none") 36 | # encrypt true|false (true) encrypt the cache value (default is "false" for the shm cache backend) 37 | # passphrase_hash_algo (sha256) hash algorithm to apply to the passphrase before using it as an encryption key 38 | # 39 | # shm: 40 | # 41 | # max_key_size (65) maximum size of the cache key in bytes (see also: key_hash_algo) 42 | # max_val_size (8193) maximum size of a single cache value 43 | # max_entries (1000) maximum number of entries in the cache (FIFO policy, overruns will result in a warning in the log) 44 | # 45 | # file: 46 | # 47 | # dir (/tmp or C:\\Temp) cache file directory 48 | # clean_interval (60) minimum interval to loop over the cache directories looking to delete expired entries 49 | # 50 | # memcache: 51 | # 52 | # config_string (--SERVER=localhost) memcached specific server configuration string, see: https://www.systutorials.com/docs/linux/man/3-memcached/ 53 | # 54 | # redis: 55 | # 56 | # host (localhost) Redis server hostname 57 | # port (6379) Redis servver port 58 | # username () username used to authenticate to the Redis server 59 | # password () password used to authenticate to the Redis server 60 | 61 | 62 | 63 | # 64 | # Set token verification method and options. 65 | # 66 | # This primitive can be used multiple times in which case the access token will be verified in 67 | # order - according to each consecutive primitive - until it validates or reaches the end of the list. 68 | # See below for a detailed list of (fine-grained) configuration options. 69 | # 70 | #OAuth2TokenVerify [] 71 | # 72 | # Samples: 73 | # 74 | # OAuth2TokenVerify introspect https://pingfed:9031/as/introspect.oauth2 introspect.ssl_verify=false&introspect.auth=client_secret_basic&client_id=rs0&client_secret=2Federate 75 | # OAuth2TokenVerify jwks_uri https://pingfed:9031/ext/one jwks_uri.ssl_verify=false 76 | # 77 | # Types: 78 | # 79 | # (provided in query-encoded format) 80 | # 81 | # introspect RFC7662 introspection URL introspect.ssl_verify, introspect.auth, introspect.cache, introspect.expiry, introspect.token_param_name, introspect.params, type 82 | # jwks_uri JWKS URI that serves the public keys jwks_uri.ssl_verify, jwks_uri.cache, jwks_uri.expiry, type, 83 | # verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after 84 | # jwk JWK JSON representation of a symmetric kid (overrides kid in JWK), verify.iss, verify.exp, verify.iat, type, 85 | # key or a public key verify.iat.slack_before, verify.iat.slack_after 86 | # metadata RFC8414 Authorization Server Metadata metadata.ssl_verify, introspect.*, jwks_uri.* 87 | # URL that contains a JWKs URI in jwks_uri 88 | # plain symmetric key (password) in plain text kid, verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after, type 89 | # base64 base64-encoded symmetric key kid, verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after, type 90 | # base64url base64url-encoded symmetric key kid, verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after, type 91 | # hex hex-encoded symmetric key kid, verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after, type 92 | # pem PEM formatted X.509 certificate kid, verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after, type 93 | # that contains an RSA public key 94 | # pubkey PEM formatted RSA public key kid, verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after, type 95 | # eckey_uri URL on wich the Elliptic Curve key is eckey_uri.ssl_verify, eckey_uri.cache, eckey_uri.expiry, 96 | # published as a PEM (Amazon ALB specific) verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after 97 | # aws_alb ALB ARN alb_base_url, aws_alb.ssl_verify, aws_alb.auth, aws_alb.cache, aws_alb.expiry 98 | # verify.iss, verify.exp, verify.iat, verify.iat.slack_before, verify.iat.slack_after 99 | # 100 | # OAuth2TokenVerify Options: 101 | # 102 | # 103 | # 104 | # kid JWK kid value to be found in JWT header 105 | # verify.iss skip|optional|required how to validate the "iss" claim in the JWT: skip it, verify if present, require claim to be present and validate 106 | # verify.exp skip|optional|required how to validate the "exp" claim in the JWT: skip it, verify if present, require claim to be present and validate 107 | # verify.iat skip|optional|required how to validate the "iat" claim in the JWT: skip it, verify if present, require claim to be present and validate 108 | # verify.iat.slack_before acceptable clock drift in seconds for the "iat" claim: anything issued before now-number will be rejected 109 | # verify.iat.slack_after acceptable clock drift in seconds for the "iat" claim: anything issued after now+number will be rejected 110 | # type [mtls|dpop] type of proof of possession, mtls.policy=[optional|required] 111 | # verify.cache cache backend name for access token validation results, 112 | # default is "default", otherwise must refer to a named cache defined with OAuth2Cache 113 | # expiry cache expiry in seconds for access token validation results 114 | # introspect.auth endpoint authentication, see Authentication Options 115 | # introspect.token_param_name name of the parameter in which the access token is sent, if is not the default "token" 116 | # introspect.params form-encoded extra POST parameters sent to the introspectoin endpoint e.g. key1%3Done%26key2%3Dtwo 117 | # *.ssl_verify true|false verify the TLS certificate presented on the configured HTTPs URL 118 | # *.cache [introspect|jwks_uri|eckey_uri|aws_alb] cache backend name for content resolved from a URI 119 | # default is "default", otherwise must refer to a named cache defined with OAuth2Cache 120 | # *.expiry [introspect|jwks_uri|eckey_uri|aws_alb] cache expiry for content resolved from a URI 121 | # 122 | # Authentication Options: 123 | # 124 | # 125 | # 126 | # none no authentication towards the endpoint is used 127 | # client_secret_basic client_id, client_secret OIDC client secret basic authentication, URL-encoded values in HTTP Basic Authentication 128 | # client_secret_post client_id, client_secret OIDC client secret post based authentication, values in HTTP POST parameters 129 | # client_secret_jwt client_id, client_secret, aud OIDC client secret JWT, providing a symmetric key in the client_secret value 130 | # private_key_jwt client_id, jwk, aud OIDC private key JWT, providing a JWK in escaped JSON string representation 131 | # client_cert cert, key TLS Client Certificate authentication, providing paths to PEM-formatted files 132 | # basic username,password HTTP basic authentication 133 | 134 | 135 | 136 | # 137 | # (Optional) 138 | # 139 | # Configures in which format access tokens can be presented. Can be provided multiple times. 140 | # 141 | # 142 | # 143 | # environment name= retrieve from environment variable 144 | # header name=&type= retrieve from header using separator (default="bearer") 145 | # query name= retrieve from query parameter 146 | # post name= retrieve from HTTP form post parameter 147 | # cookie name= retrieve from cookie 148 | # basic retrieve from basic authentication header password value 149 | # 150 | #OAuth2AcceptTokenIn [] 151 | 152 | 153 | 154 | # (Optional) 155 | # 156 | # Configures in which format claims and informations from the token validation results are passed to the target application. 157 | # 158 | #