This is a GOLANG application plugin deigned to work with keycloak for authentication
To create a connection with your keycloak client you will need add the 'Keycloak OIDC JSON' file to <$AppHomeDir>/json/ folder.
This file can be found in the Keycloak Console in Clients → <$ClientName> → Installation
Init will create the connection between the keycloak client and your application
Params:
Init(keycloakserver string, server string)
Calling:
server = "http://" + <$AppHost> + ":" + <$AppPort>
keycloakserver = "http://" + <$KeycloakHost> + ":" + <$KeycloakPort>
keycloak.Init(keycloakserver, server)
Login and LoginCallback will direct the user the login screen and verify their login token
Params:
HandleLogin(w http.ResponseWriter, r *http.Request)
HandleLoginCallback(w http.ResponseWriter, r *http.Request)
Calling:
//Login User
//Unauthenticated
Route{
"handleLogin",
"GET",
"/login",
keycloak.HandleLogin,
},
//Login helper
//Authenticated
Route{
"handleLoginCallback",
"GET",
"/loginCallback",
keycloak.HandleLoginCallback,
},
Middleware provides a means to have users authenticated before accessing a page
Params:
AuthMiddleware(next http.HandlerFunc) http.HandlerFunc
Calling:
//Example Function Redirect
//Authenticated
//indexHandler is an http.HandlerFunc
Route{
"Index",
"GET",
"/",
keycloak.AuthMiddleware(indexHandler),
},
Middleware provides a means to have users authenticated before accessing a page
Params:
Logout(w http.ResponseWriter, r *http.Request)
Calling:
//Logout, redirects to login
///Unauthenticatec
Route{
"logout",
"GET",
"/logout",
keycloak.Logout,
},