Skip to content

Instantly share code, notes, and snippets.

@hardselius
Created February 9, 2018 11:23
Show Gist options
  • Select an option

  • Save hardselius/478f68b97a18c68d9981cf373416b9f3 to your computer and use it in GitHub Desktop.

Select an option

Save hardselius/478f68b97a18c68d9981cf373416b9f3 to your computer and use it in GitHub Desktop.
Look at https://github.com/gambol99/keycloak-proxy for setting up the proxy and the rules 'n stuff.
Basically, what you need to do is
- create a client in Keycloak,
- run the proxy from the command line, and
- open a browser and
bin/keycloak-proxy \
--discovery-url=http://localhost:8000/realms/telia \
--client-id=keycloak-proxy \
--client-secret=9a3a63d9-1b9d-4a33-bf3d-a6d60393cc2a \
--listen=127.0.0.1:3333 \
--redirection-url=http://localhost:3131 \
--enable-refresh-tokens=true \
--encryption-key=AgXa7xRcoClDEU0ZDSH4X0XhL5Qy2Z2j \
--upstream-url=http://localhost:3131 \
--skip-upstream-tls-verify=true \
--secure-cookie=false \
--resources="uri=/protected*|methods=GET|roles=user"
This isn't fully working. Figure it out.
package main
import (
"net/http"
)
func main() {
http.Handle("/", http.FileServer(http.Dir("./resources/")))
http.ListenAndServe(":3131", nil);
}
<!-- resources/open.html -->
<html>
<head>
<title>DEMO</title>
</head>
<body>
<h2>This is open</h2>
<a href="protected.html">PROTECTED</a>
</body>
</html>
<!-- resources/protected.html -->
<html>
<head>
<title>DEMO</title>
</head>
<body>
<h2>This is protected</h2>
<a href="open.html">OPEN</a>
<a href="oauth/logout?redirect=http://localhost:3333/open.html">LOGOUT</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment