user

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CookieExpirationTime int
	JwtExpirationTime    int
)
View Source
var Claims struct {
	Email    string   `json:"email"`
	Verified bool     `json:"email_verified"`
	Groups   []string `json:"groups"`
	Token    string   `json:"token"`
	Roles    []string `json:"roles"`
	jwt.StandardClaims
}

Functions

func Authorizer

func Authorizer(e *casbin.Enforcer, sessionManager *session.SessionManager) func(next http.Handler) http.Handler

Authorizer is a middleware for authorization

Types

type ACDAuthConfig

type ACDAuthConfig struct {
	ACDUsername           string `env:"ACD_USERNAME" `
	ACDPassword           string `env:"ACD_PASSWORD" `
	ACDConfigMapName      string `env:"ACD_CM" envDefault:"argocd-cm"`
	ACDConfigMapNamespace string `env:"ACD_NAMESPACE" envDefault:"devtroncd"`
}

func GetACDAuthConfig

func GetACDAuthConfig() (*ACDAuthConfig, error)

type DexConfig

type DexConfig struct {
	RedirectURL          string `env:"DEX_RURL" envDefault:"http://127.0.0.1:8080/callback"`
	ClientID             string `env:"DEX_CID" envDefault:"example-app"`
	ClientSecret         string `env:"DEX_SECRET" `
	DexURL               string `env:"DEX_URL" `
	DexJwtKey            string `env:"DEX_JWTKEY" `
	CStoreKey            string `env:"DEX_CSTOREKEY"`
	CookieExpirationTime int    `env:"CExpirationTime" envDefault:"600"`
	JwtExpirationTime    int    `env:"JwtExpirationTime" envDefault:"120"`
}

func GetConfig

func GetConfig() (*DexConfig, error)

type RoleGroupService

type RoleGroupService interface {
	CreateRoleGroup(request *bean.RoleGroup) (*bean.RoleGroup, error)
	UpdateRoleGroup(request *bean.RoleGroup) (*bean.RoleGroup, error)

	FetchRoleGroupsById(id int32) (*bean.RoleGroup, error)
	FetchRoleGroups() ([]*bean.RoleGroup, error)
	FetchRoleGroupsByName(name string) ([]*bean.RoleGroup, error)
	DeleteRoleGroup(model *bean.RoleGroup) (bool, error)
}

type RoleGroupServiceImpl

type RoleGroupServiceImpl struct {
	// contains filtered or unexported fields
}

func NewRoleGroupServiceImpl

func NewRoleGroupServiceImpl(userAuthRepository repository.UserAuthRepository, sessionManager *session.SessionManager,
	client session2.ServiceClient, logger *zap.SugaredLogger, userRepository repository.UserRepository,
	roleGroupRepository repository.RoleGroupRepository) *RoleGroupServiceImpl

func (RoleGroupServiceImpl) CreateRoleGroup

func (impl RoleGroupServiceImpl) CreateRoleGroup(request *bean.RoleGroup) (*bean.RoleGroup, error)

func (RoleGroupServiceImpl) DeleteRoleGroup

func (impl RoleGroupServiceImpl) DeleteRoleGroup(bean *bean.RoleGroup) (bool, error)

func (RoleGroupServiceImpl) FetchRoleGroups

func (impl RoleGroupServiceImpl) FetchRoleGroups() ([]*bean.RoleGroup, error)

func (RoleGroupServiceImpl) FetchRoleGroupsById

func (impl RoleGroupServiceImpl) FetchRoleGroupsById(id int32) (*bean.RoleGroup, error)

func (RoleGroupServiceImpl) FetchRoleGroupsByName

func (impl RoleGroupServiceImpl) FetchRoleGroupsByName(name string) ([]*bean.RoleGroup, error)

func (RoleGroupServiceImpl) UpdateRoleGroup

func (impl RoleGroupServiceImpl) UpdateRoleGroup(request *bean.RoleGroup) (*bean.RoleGroup, error)

type TokenCache

type TokenCache struct {
	// contains filtered or unexported fields
}

func NewTokenCache

func NewTokenCache(logger *zap.SugaredLogger, aCDAuthConfig *ACDAuthConfig, userAuthService UserAuthService) *TokenCache

func (*TokenCache) BuildACDSynchContext

func (impl *TokenCache) BuildACDSynchContext() (acdContext context.Context, err error)

type User

type User struct {
	// contains filtered or unexported fields
}

type UserAuthService

type UserAuthService interface {
	HandleLogin(username string, password string) (string, error)
	HandleDexCallback(w http.ResponseWriter, r *http.Request)
	HandleRefresh(w http.ResponseWriter, r *http.Request)

	CreateRole(roleData *bean.RoleData) (bool, error)
	UpdateRole(roleData *bean.RoleData) (bool, error)
	GetRolesByUserId(userId int32) ([]bean.Role, error)
	GetAllRole() ([]bean.Role, error)
	GetRoleByFilter(entity string, team string, app string, env string, act string) (bean.Role, error)
	DeleteRole(role string) (bool, error)
	AuthVerification(r *http.Request) (bool, error)
}

type UserAuthServiceImpl

type UserAuthServiceImpl struct {
	// contains filtered or unexported fields
}

func NewUserAuthServiceImpl

func NewUserAuthServiceImpl(userAuthRepository repository.UserAuthRepository, sessionManager *session.SessionManager,
	client session2.ServiceClient, logger *zap.SugaredLogger, userRepository repository.UserRepository,
) *UserAuthServiceImpl

func (UserAuthServiceImpl) AuthVerification

func (impl UserAuthServiceImpl) AuthVerification(r *http.Request) (bool, error)

func (UserAuthServiceImpl) CreateRole

func (impl UserAuthServiceImpl) CreateRole(roleData *bean.RoleData) (bool, error)

func (UserAuthServiceImpl) DeleteRole

func (impl UserAuthServiceImpl) DeleteRole(role string) (bool, error)

func (UserAuthServiceImpl) GetAllRole

func (impl UserAuthServiceImpl) GetAllRole() ([]bean.Role, error)

func (UserAuthServiceImpl) GetRoleByFilter

func (impl UserAuthServiceImpl) GetRoleByFilter(entity string, team string, app string, env string, act string) (bean.Role, error)

func (UserAuthServiceImpl) GetRolesByUserId

func (impl UserAuthServiceImpl) GetRolesByUserId(userId int32) ([]bean.Role, error)

func (UserAuthServiceImpl) HandleDexCallback

func (impl UserAuthServiceImpl) HandleDexCallback(w http.ResponseWriter, r *http.Request)

func (UserAuthServiceImpl) HandleLogin

func (impl UserAuthServiceImpl) HandleLogin(username string, password string) (string, error)

func (UserAuthServiceImpl) HandleRefresh

func (impl UserAuthServiceImpl) HandleRefresh(w http.ResponseWriter, r *http.Request)

func (UserAuthServiceImpl) UpdateRole

func (impl UserAuthServiceImpl) UpdateRole(roleData *bean.RoleData) (bool, error)

type UserService

type UserService interface {
	CreateUser(userInfo *bean.UserInfo) ([]*bean.UserInfo, error)
	UpdateUser(userInfo *bean.UserInfo) (*bean.UserInfo, error)
	GetById(id int32) (*bean.UserInfo, error)
	GetAll() ([]bean.UserInfo, error)
	GetUsersByFilter(size int, from int) ([]bean.UserInfo, error)

	GetUserByEmail(emailId string) (*bean.UserInfo, error)
	GetLoggedInUser(r *http.Request) (int32, error)
	GetByIds(ids []int32) ([]bean.UserInfo, error)
	DeleteUser(userInfo *bean.UserInfo) (bool, error)
	CheckUserRoles(id int32) ([]string, error)
	SyncOrchestratorToCasbin() (bool, error)
	GetUserByToken(token string) (int32, error)
	IsSuperAdmin(userId int) (bool, error)
}

type UserServiceImpl

type UserServiceImpl struct {
	// contains filtered or unexported fields
}

func NewUserServiceImpl

func NewUserServiceImpl(userAuthRepository repository.UserAuthRepository, sessionManager *session.SessionManager,
	client session2.ServiceClient, logger *zap.SugaredLogger, userRepository repository.UserRepository,
	userGroupRepository repository.RoleGroupRepository) *UserServiceImpl

func (UserServiceImpl) CheckUserRoles

func (impl UserServiceImpl) CheckUserRoles(id int32) ([]string, error)

func (UserServiceImpl) CreateUser

func (impl UserServiceImpl) CreateUser(userInfo *bean.UserInfo) ([]*bean.UserInfo, error)

func (UserServiceImpl) DeleteUser

func (impl UserServiceImpl) DeleteUser(bean *bean.UserInfo) (bool, error)

func (UserServiceImpl) GetAll

func (impl UserServiceImpl) GetAll() ([]bean.UserInfo, error)

func (UserServiceImpl) GetById

func (impl UserServiceImpl) GetById(id int32) (*bean.UserInfo, error)

func (UserServiceImpl) GetByIds

func (impl UserServiceImpl) GetByIds(ids []int32) ([]bean.UserInfo, error)

func (UserServiceImpl) GetLoggedInUser

func (impl UserServiceImpl) GetLoggedInUser(r *http.Request) (int32, error)

func (UserServiceImpl) GetUserByEmail

func (impl UserServiceImpl) GetUserByEmail(emailId string) (*bean.UserInfo, error)

func (UserServiceImpl) GetUserByToken

func (impl UserServiceImpl) GetUserByToken(token string) (int32, error)

func (UserServiceImpl) GetUsersByFilter

func (impl UserServiceImpl) GetUsersByFilter(size int, from int) ([]bean.UserInfo, error)

func (UserServiceImpl) IsSuperAdmin

func (impl UserServiceImpl) IsSuperAdmin(userId int) (bool, error)

func (UserServiceImpl) SyncOrchestratorToCasbin

func (impl UserServiceImpl) SyncOrchestratorToCasbin() (bool, error)

func (UserServiceImpl) UpdateUser

func (impl UserServiceImpl) UpdateUser(userInfo *bean.UserInfo) (*bean.UserInfo, error)

type WebhookToken

type WebhookToken struct {
	WebhookToken string `env:"WEBHOOK_TOKEN" envDefault:""`
}

func GetWebhookToken

func GetWebhookToken() (*WebhookToken, error)

Jump to

Keyboard shortcuts

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