This Go project decrypts OAuth2 proxy cookies using a shared secret defined in the .env file. The program is designed to read and decrypt the combined cookie values of _oauth2_proxy_0 and _oauth2_proxy_1.
- Go 1.16+ (or a later version)
- .env file for secret management
-
Clone the repository:
git clone https://github.com/sanderkoenders/oauth2-proxy-cookie-decrypter.git cd oauth2-proxy-cookie-decrypter -
Install dependencies:
If you're using Go Modules, dependencies should automatically be fetched. Otherwise, run the following command:
go mod tidy
-
Create the
.envfile:In the root of your project, create a
.envfile and define theCOOKIE_SECRETvariable. It should contain the secret used for cookie encryption.Example
.envfile:COOKIE_SECRET=my-secret-key -
Build the project:
go build -o decrypt-cookie
-
Run the program:
The program expects the combined cookie values of
_oauth2_proxy_0and_oauth2_proxy_1as a single argument (enclosed in quotes). For example:./decrypt-cookie "<_oauth2_proxy_0><_oauth2_proxy_1>"- Replace
_oauth2_proxy_0and_oauth2_proxy_1with the actual combined cookie values.
- Replace
Assuming the values for _oauth2_proxy_0 and _oauth2_proxy_1 are _oauth2_proxy_0 and _oauth2_proxy_1, run the following command:
./decrypt-cookie "<_oauth2_proxy_0><_oauth2_proxy_1>"The program will output the decrypted IDToken and AccessToken.
- Ensure the
.envfile is not committed to version control. You can add it to.gitignoreto prevent accidental commits.