OpenID Connect resource demo application
Find a file
Jan Dittberner 7ec9e393e0 Add separate protected resource page
This commit adds a separate protected resource page to demonstrate how
to selectively require logins.

Add code to improve client performance by providing modification timestamps
and Cache-Control headers for embedded static files.
2023-08-03 16:46:28 +02:00
cmd/app Add separate protected resource page 2023-08-03 16:46:28 +02:00
debian Add packaging via goreleaser 2023-07-29 18:23:28 +02:00
docs Add packaging via goreleaser 2023-07-29 18:23:28 +02:00
internal Add separate protected resource page 2023-08-03 16:46:28 +02:00
translations Add separate protected resource page 2023-08-03 16:46:28 +02:00
ui Add separate protected resource page 2023-08-03 16:46:28 +02:00
.gitignore Add separate protected resource page 2023-08-03 16:46:28 +02:00
.golangci.yml Modernize demo application 2023-07-29 17:46:33 +02:00
.goreleaser.yml Add packaging via goreleaser 2023-07-29 18:23:28 +02:00
changelog.md Add separate protected resource page 2023-08-03 16:46:28 +02:00
go.mod Modernize demo application 2023-07-29 17:46:33 +02:00
go.sum Modernize demo application 2023-07-29 17:46:33 +02:00
Makefile Add separate protected resource page 2023-08-03 16:46:28 +02:00
README.md Update Copyright in README.md 2023-07-29 18:35:29 +02:00

Demo OpenID connect application

This repository contains a demo application using OAuth2/OpenID Connect to authenticate and authorize users.

The code in this repository is licensed under the terms of the Apache License Version 2.0.

Copyright © 2020-2023 CAcert Inc.

Setup

Certificates

You need a server certificate and corresponding private key to run demo-app.

An easy way to generate server certificate and key for local testing is mkcert.

Run mkcert to generate app.cacert.localhost.pem and app.cacert.localhost-key.pem:

mkcert -cert-file app.cacert.localhost

Configure the Demo Application

You will need a 32 byte and a 64 byte random secret for the session authentication and encryption keys:

openssl rand -base64 64
openssl rand -base64 32

You also need the client id and the client secret, that have been generated during the OIDC client setup described above.

Put the data into resource_app.toml:

[oidc]
client-id = "<client id from hydra clients invocation>"
client-secret = "<client secret from hydra clients invocation>"

[session]
auth-key = "<64 bytes of base64 encoded data>"
enc-key = "<32 bytes of base64 encoded data>"

Start

Now you can start the demo application:

make
./demo-app

Visit https://app.cacert.localhost:4000/ in a Browser and you will be directed through the OpenID connect authorization code flow.

Translations

This application uses go-i18n for internationalization (i18n) support.

The translation workflow needs the go18n binary which can be installed via

go install github.com/nicksnyder/go-i18n/v2/goi18n

To extract new messages from the code run

cd translations
goi18n extract ..

Then use

cd translations
goi18n merge active.*.toml

to create TOML files for translation as translate.<locale>.toml.

After translating the messages run

cd translations
goi18n merge active.*.toml translate.*.toml

to merge the messages back into the active translation files. To add a new language you need to add the language code to the languages configuration option (default is defined in the configmap in services/configuration.go).