auth

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdminJWT *gocloak.JWT
View Source
var Certificates jose.JSONWebKeySet
View Source
var Client string
View Source
var ClientID string
View Source
var ClientSecret string
View Source
var Realm *string
View Source
var RealmManagementClientId string
View Source
var Server string

Functions

func GetAdminToken

func GetAdminToken(ctx context.Context, username string, password string, realm string) (*gocloak.JWT, error)

func GetToken

func GetToken(ctx context.Context, username string, password string, clientId string, realm string) (*gocloak.JWT, error)

func InitKeycloak

func InitKeycloak(ctx context.Context, username string, password string, realm string, server string) error

Init Keycloak one time

func RefreshToken

func RefreshToken(ctx context.Context, refreshToken string, realm string, clientID string) (*gocloak.JWT, error)

refresh

func UpdateAttributesUser

func UpdateAttributesUser(ctx context.Context, email string, realm string, attributes map[string][]string) (bool, error)

func ValidateStruct

func ValidateStruct(request LoginRequest) *utils.ApiError

Types

type AuthHandler

type AuthHandler struct {
	Service *AuthService
}

func (*AuthHandler) Login

func (h *AuthHandler) Login(c *fiber.Ctx) error

Login godoc @Summary Login @Description Login @Tags keycloak @Accept json @Param request body LoginRequest true "request" @Produce json @Success 200 {object} AuthResponse @Router /auth/login [post]

type AuthResponse

type AuthResponse struct {
	Token string `json:"token"`
}

type AuthService

type AuthService struct {
}

func (*AuthService) Login

func (s *AuthService) Login(username string, password string) (*AuthResponse, error)

type AuthStore

type AuthStore interface {
	Login(username string, password string) // need to add jwt
}

type GoCloakAuthStore

type GoCloakAuthStore struct {
	GCloakClient gocloak.GoCloak
}

func (*GoCloakAuthStore) Login

func (s *GoCloakAuthStore) Login(username string, password string)

type KeycloakMutexWrapper

type KeycloakMutexWrapper struct {
	Mu sync.Mutex
	gocloak.GoCloak
}

keycloak Mutex Wrapper to prevent leak memory and problem with concurrent access

var GCloakClient KeycloakMutexWrapper

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LogoutRequest

type LogoutRequest struct {
	RefreshToken string `json:"refresh_token"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL