Documentation ¶
Overview ¶
YetAnotherToDoList Copyright © 2023 gilex-dev gilex-dev@proton.me
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
YetAnotherToDoList Copyright © 2023 gilex-dev gilex-dev@proton.me
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
YetAnotherToDoList Copyright © 2023 gilex-dev gilex-dev@proton.me
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
YetAnotherToDoList Copyright © 2023 gilex-dev gilex-dev@proton.me
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
YetAnotherToDoList Copyright © 2023 gilex-dev gilex-dev@proton.me
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Variables
- func RevokeAccessToken(accessToken *AccessToken)
- func ValidatePassword(password string) error
- func ValidateUserName(userName string) error
- type AccessToken
- type CustomDB
- func (db CustomDB) AddUserRole(userId string, roleId string, isRoleManager bool) (relationId string, err error)
- func (db CustomDB) CheckAccessToken(encAccessToken string) (accessToken *AccessToken, err error)
- func (db CustomDB) CleanExpiredRefreshTokensTicker(interval time.Duration) (stopCleaner chan bool)
- func (db CustomDB) CleanRevokedAccessTokensTicker(interval time.Duration) (stopCleaner chan bool)
- func (db CustomDB) CreateInitialAdmin(initialAdminName string, initialAdminPassword string) error
- func (db CustomDB) CreateRole(newRole *model.NewRole) (role *model.Role, err error)
- func (db CustomDB) CreateTodo(newTodo model.NewTodo) (*model.Todo, error)
- func (db CustomDB) CreateUser(newUser model.NewUser) (*model.User, error)
- func (db CustomDB) DeleteRole(roleId string) (*string, error)
- func (db CustomDB) DeleteTodo(todoId string) (deletedTodoId *string, err error)
- func (db CustomDB) DeleteUser(userId string) (*string, error)
- func (db CustomDB) GenerateHashFromPassword(password string) (passwordHash []byte, err error)
- func (db CustomDB) GetAllRefreshTokens() ([]*model.RefreshToken, error)
- func (db CustomDB) GetAllRoles() ([]*model.Role, error)
- func (db CustomDB) GetAllTodos() ([]*model.Todo, error)
- func (db CustomDB) GetAllUsers() ([]*model.User, error)
- func (db CustomDB) GetOwner(todoId string) (string, error)
- func (db CustomDB) GetRefreshToken(token *model.RefreshToken) (*model.RefreshToken, error)
- func (db CustomDB) GetRefreshTokenOwner(tokenId string) (ownerId string, err error)
- func (db CustomDB) GetRefreshTokensFrom(userId string) ([]*model.RefreshToken, error)
- func (db CustomDB) GetRole(role *model.Role) (*model.Role, error)
- func (db CustomDB) GetRoleMembers(roleId string) ([]*model.RelationRoleUser, error)
- func (db CustomDB) GetRolesFrom(userId string) ([]*model.RelationUserRole, error)
- func (db CustomDB) GetTodo(todo *model.Todo) (*model.Todo, error)
- func (db CustomDB) GetTodoOwner(todo *model.Todo) (owner *model.User, err error)
- func (db CustomDB) GetTodosFrom(user *model.User) ([]*model.Todo, error)
- func (db CustomDB) GetUser(user *model.User) (*model.User, error)
- func (db CustomDB) GetUserPermissions(userId string) (isAdmin bool, isUserCreator bool, err error)
- func (db CustomDB) IssueAccessToken(refreshToken *RefreshToken) (*AccessToken, error)
- func (db CustomDB) IssueRefreshToken(userId string, tokenName *string) (refreshToken *RefreshToken, refreshTokenId string, err error)
- func (db CustomDB) RemoveUserRole(userId string, roleId string) (relationId string, err error)
- func (db CustomDB) RevokeRefreshToken(tokenId string) (*string, error)
- func (db CustomDB) SignAccessToken(accessToken AccessToken) (encAccessToken string, err error)
- func (db CustomDB) UpdateRefreshToken(tokenId string, changes *model.UpdateRefreshToken) (*model.RefreshToken, error)
- func (db CustomDB) UpdateRole(roleId string, changes *model.UpdateRole) (*model.Role, error)
- func (db CustomDB) UpdateTodo(todoId string, changes *model.UpdateTodo) (*model.Todo, error)
- func (db CustomDB) UpdateUser(userId string, changes *model.UpdateUser) (*model.User, error)
- func (db CustomDB) UpdateUserRole(userId string, roleId string, isRoleManager bool) (relationId string, err error)
- func (db CustomDB) ValidateUserCredentials(userId *string, userName *string, password string) (validUserId string, err error)
- type RefreshToken
Constants ¶
This section is empty.
Variables ¶
var RevokedAccessTokens []*AccessToken
Functions ¶
func RevokeAccessToken ¶
func RevokeAccessToken(accessToken *AccessToken)
RevokeAccessToken revokes all access tokens with matching UserId and UserRole that don't have a later ExpiryDate. revokedAccessToken.ExpiryDate should be set to now + token-lifetime.
func ValidatePassword ¶
ValidatePassword validates the passed string against the password criteria.
func ValidateUserName ¶
ValidateUserName validates the passed string against the user name criteria.
Types ¶
type AccessToken ¶
type CustomDB ¶
type CustomDB struct {
// contains filtered or unexported fields
}
func InitSQLite3 ¶
func (CustomDB) AddUserRole ¶
func (CustomDB) CheckAccessToken ¶
func (db CustomDB) CheckAccessToken(encAccessToken string) (accessToken *AccessToken, err error)
func (CustomDB) CleanExpiredRefreshTokensTicker ¶
func (CustomDB) CleanRevokedAccessTokensTicker ¶
CleanRevokedTokensTicker removes expired tokens from the list. This should be called in an interval of > accessTokenLifetime.
func (CustomDB) CreateInitialAdmin ¶
func (CustomDB) CreateRole ¶
func (CustomDB) CreateTodo ¶
CreateTodo creates a Todo for the passed newTodo.UserID. Check if the source has the rights to call this.
func (CustomDB) CreateUser ¶
func (CustomDB) DeleteTodo ¶
func (CustomDB) GenerateHashFromPassword ¶
GenerateHashFromPassword generates a hash of the passed password. Returns salt and salted & peppered hash.
func (CustomDB) GetAllRefreshTokens ¶
func (db CustomDB) GetAllRefreshTokens() ([]*model.RefreshToken, error)
func (CustomDB) GetAllTodos ¶
GetAllTodos gets all todos from the database. Check if the source has the rights to call this.
func (CustomDB) GetOwner ¶
GetOwner takes a todoId and return the owner's userId. Call before Update/Get/DeleteTodo when not IS_admin.
func (CustomDB) GetRefreshToken ¶
func (db CustomDB) GetRefreshToken(token *model.RefreshToken) (*model.RefreshToken, error)
func (CustomDB) GetRefreshTokenOwner ¶
GetRefreshTokenOwner takes a tokenId and return the owner's userId. Call before Update/Get/DeleteRefreshToken when not IS_admin.
func (CustomDB) GetRefreshTokensFrom ¶
func (db CustomDB) GetRefreshTokensFrom(userId string) ([]*model.RefreshToken, error)
func (CustomDB) GetRoleMembers ¶
func (db CustomDB) GetRoleMembers(roleId string) ([]*model.RelationRoleUser, error)
func (CustomDB) GetRolesFrom ¶
func (db CustomDB) GetRolesFrom(userId string) ([]*model.RelationUserRole, error)
func (CustomDB) GetTodo ¶
GetTodo takes a *model.Todo with at least ID set and adds the missing fields.
func (CustomDB) GetTodoOwner ¶
GetTodoOwner takes a *model.Todo with at least ID set and returns an *model.User with Id set to the todo's owner Id.
func (CustomDB) GetTodosFrom ¶
GetTodosFrom gets all todos from the passed *model.User. ID must be set.
func (CustomDB) GetUser ¶
GetUser takes a *model.User with at least ID or UserName set and adds the missing fields.
func (CustomDB) GetUserPermissions ¶
func (CustomDB) IssueAccessToken ¶
func (db CustomDB) IssueAccessToken(refreshToken *RefreshToken) (*AccessToken, error)
IssueAccessToken issues an access token if the passed refresh token is valid. Returned access token must be passed to SignAccessToken to be accepted.
func (CustomDB) IssueRefreshToken ¶
func (db CustomDB) IssueRefreshToken(userId string, tokenName *string) (refreshToken *RefreshToken, refreshTokenId string, err error)
IssueRefreshToken issues a refresh token if the passed user credentials are valid. Returned refresh token can be passed to IssueAccessToken.
func (CustomDB) RemoveUserRole ¶
func (CustomDB) RevokeRefreshToken ¶
RevokeRefreshToken revokes the access token matching the tokenId. Also calls RevokeAccessToken.
func (CustomDB) SignAccessToken ¶
func (db CustomDB) SignAccessToken(accessToken AccessToken) (encAccessToken string, err error)
SignAccessToken signs an access token and attaches a header. Returns access token encoded as jwt.
func (CustomDB) UpdateRefreshToken ¶
func (db CustomDB) UpdateRefreshToken(tokenId string, changes *model.UpdateRefreshToken) (*model.RefreshToken, error)