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
.env
file:In the root of your project, create a
.env
file and define theCOOKIE_SECRET
variable. It should contain the secret used for cookie encryption.Example
.env
file: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_0
and_oauth2_proxy_1
as a single argument (enclosed in quotes). For example:./decrypt-cookie "<_oauth2_proxy_0><_oauth2_proxy_1>"
- Replace
_oauth2_proxy_0
and_oauth2_proxy_1
with 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
.env
file is not committed to version control. You can add it to.gitignore
to prevent accidental commits.