All Projects → Clarilab → gocloaksession

Clarilab / gocloaksession

Licence: Apache-2.0 License
Maintains an active keycloak session using gocloak

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gocloaksession

vertx-vue-keycloak
This repo holds the source codes for the Medium Article "Vert.x + VueJS + OAuth2 in 5 steps"
Stars: ✭ 20 (+33.33%)
Mutual labels:  keycloak
kibana-keycloak
Secure kibana dashboards using keycloak
Stars: ✭ 40 (+166.67%)
Mutual labels:  keycloak
keycloak-sms-authenticator-sns
SMS 2 Factor Authentication for Keycloak via AWS SNS
Stars: ✭ 66 (+340%)
Mutual labels:  keycloak
springboot-keycloak-openldap
The goal of this project is to create a simple Spring Boot REST API, called simple-service, and secure it with Keycloak. Furthermore, the API users will be loaded into Keycloak from OpenLDAP server.
Stars: ✭ 96 (+540%)
Mutual labels:  keycloak
keycloak-heroku
Deploy Keycloak to Heroku using a slightly adapted version of the official docker image
Stars: ✭ 47 (+213.33%)
Mutual labels:  keycloak
keycloakify
🔏 Create Keycloak themes using React
Stars: ✭ 451 (+2906.67%)
Mutual labels:  keycloak
springboot-react-keycloak
The goal of this project is to secure movies-app using Keycloak(with PKCE). movies-app consists of two applications: one is a Spring Boot Rest API called movies-api and another is a ReactJS application called movies-ui.
Stars: ✭ 192 (+1180%)
Mutual labels:  keycloak
brauzie
Awesome CLI for fetching JWT tokens for OAuth2.0 clients
Stars: ✭ 14 (-6.67%)
Mutual labels:  keycloak
horusec-platform
Horusec Platform is a set of web services that integrate with the Horusec CLI to facilitate the visualization and management of found vulnerabilities.
Stars: ✭ 32 (+113.33%)
Mutual labels:  keycloak
epiphany
Cloud and on-premises automation for Kubernetes centered industrial grade solutions.
Stars: ✭ 114 (+660%)
Mutual labels:  keycloak
keycloak-sso-configs
common keycloak single sign on configurations
Stars: ✭ 19 (+26.67%)
Mutual labels:  keycloak
beercloak
BeerCloak: a comprehensive Keycloak extension example
Stars: ✭ 110 (+633.33%)
Mutual labels:  keycloak
react-native-keycloak
React Native components for Keycloak
Stars: ✭ 114 (+660%)
Mutual labels:  keycloak
keycloak-home-idp-discovery
Keycloak: Home IdP Discovery - discover home identity provider or realm by email domain
Stars: ✭ 42 (+180%)
Mutual labels:  keycloak
react-keycloak-examples
Examples for react-keycloak packages
Stars: ✭ 110 (+633.33%)
Mutual labels:  keycloak
keycloak-admin-client
PHP Client to connect to Keycloak admin rest apis
Stars: ✭ 57 (+280%)
Mutual labels:  keycloak
secure-oauth2-oidc-workshop
Hands-On Workshop for OAuth 2.0 and OpenID Connect 1.0
Stars: ✭ 58 (+286.67%)
Mutual labels:  keycloak
keycloak-docker
Docker image for Keycloak 6.0.1 (postgres, ssl) + k8s + Openshift
Stars: ✭ 19 (+26.67%)
Mutual labels:  keycloak
keyonic-v2
A Keycloak Mobile Implementation using Angular v4 and Ionic v3
Stars: ✭ 23 (+53.33%)
Mutual labels:  keycloak
keycloak-session-restrictor
Simple event-listener for Keycloak which restricts the current user sessions to one (last one wins) only. Demo purposes only!
Stars: ✭ 48 (+220%)
Mutual labels:  keycloak

gocloaksession

This client uses: gocloak and resty

Installation

go get github.com/Clarilab/gocloaksession

Importing

import "github.com/Clarilab/gocloaksession"

Features

// GoCloakSession holds all callable methods
type GoCloakSession interface {
	// GetKeycloakAuthToken returns a JWT object, containing the AccessToken and more
	GetKeycloakAuthToken() (*gocloak.JWT, error)

	// Sets the Authentication Header for the response
	// Can be used as Middleware in resty
	AddAuthTokenToRequest(*resty.Client, *resty.Request) error

	// GetGoCloakInstance returns the currently used GoCloak instance.
	GetGoCloakInstance() gocloak.GoCloak

	// ForceAuthenticate ignores all checks and executes an authentication.
	ForceAuthenticate() error

	// ForceRefresh ignores all checks and executes a refresh.
	ForceRefresh() error
}

See https://github.com/Nerzal/gocloak/blob/master/token.go for complete JWT struct.

Example

// Create a new session
session := NewSession(clientId, clientSecret, realm, uri)

// Authenticate or refresh the token
token, err := session.GetKeycloakAuthToken()

If you want to use it as middleware in resty, you can use the following example

session := NewSession(clientId, clientSecret, realm, uri)

restyClient.OnBeforeRequest(session.AddAuthTokenToRequest)

In case you need the GoCloak instance to execute your own commands.

gocloakInstance := session.GetGoCloakInstance()

Developing & Testing

For local testing you need to start a docker container. Simply run following commands prior to starting the tests:

docker pull quay.io/keycloak/keycloak
docker run -d \
	-e KEYCLOAK_USER=admin \
	-e KEYCLOAK_PASSWORD=secret \
	-e KEYCLOAK_IMPORT=/tmp/gocloak-realm.json \
	-v "`pwd`/testdata/gocloak-realm.json:/tmp/gocloak-realm.json" \
	-p 8080:8080 \
	--name gocloak-test \
	quay.io/keycloak/keycloak:latest -Dkeycloak.profile.feature.upload_scripts=enabled

go test

To remove running docker container after completion of tests:

docker stop gocloak-test
docker rm gocloak-test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].