added mongo db handlers for all but server
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package mongo_db_handlers
|
||||
package mongo
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.acooldomain.co/server-manager/backend-kubernetes-go/dbhandler"
|
||||
"git.acooldomain.co/server-manager/backend-kubernetes-go/models"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@@ -16,6 +17,7 @@ type ServerPermissions struct {
|
||||
}
|
||||
|
||||
type MongoDbAuthorizationHandler struct {
|
||||
dbhandler.AuthorizationDbHandler
|
||||
collection *mongo.Collection
|
||||
}
|
||||
|
||||
@@ -136,7 +138,7 @@ func (self *MongoDbAuthorizationHandler) GetPermissions(username string, serverI
|
||||
return serverPermissions.Permissions, nil
|
||||
}
|
||||
|
||||
func NewMongoDbAuthorizationHandler(config models.MongoDBConfig) (*MongoDbAuthorizationHandler, error) {
|
||||
func NewAuthorizationHandler(config models.MongoDBConfig) (*MongoDbAuthorizationHandler, error) {
|
||||
clientOptions := options.Client().ApplyURI(config.Url).SetAuth(options.Credential{
|
||||
Username: config.Username,
|
||||
Password: config.Password,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module git.acooldomain.co/server-manager/backend-kubernetes-go/db_handler/mongo_db_handlers
|
||||
module git.acooldomain.co/server-manager/backend-kubernetes-go/db_handler/mongo
|
||||
|
||||
go 1.24.1
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package mongo_db_handlers
|
||||
package mongo
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -24,6 +24,7 @@ type Invite struct {
|
||||
}
|
||||
|
||||
type MongoDbUserPassHandler struct {
|
||||
dbhandler.UserPassAuthanticationDbHandler
|
||||
collection *mongo.Collection
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ func (self *MongoDbUserPassHandler) SetPermissions(
|
||||
return err
|
||||
}
|
||||
|
||||
func NewMMongoDbUserPassAuthHandler(config models.MongoDBConfig) (*MongoDbUserPassHandler, error) {
|
||||
func NewUserPassAuthHandler(config models.MongoDBConfig) (*MongoDbUserPassHandler, error) {
|
||||
clientOptions := options.Client().ApplyURI(config.Url).SetAuth(options.Credential{
|
||||
Username: config.Username,
|
||||
Password: config.Password,
|
||||
@@ -1,4 +1,4 @@
|
||||
package mongo_db_handlers
|
||||
package mongo
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type MongoDbUserHandler struct {
|
||||
dbhandler.UsersDBHandler
|
||||
collection *mongo.Collection
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ func (self *MongoDbUserHandler) CreateUser(user dbhandler.User) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewMMongoDbUsersHandler(config models.MongoDBConfig) (*MongoDbUserHandler, error) {
|
||||
func NewUsersHandler(config models.MongoDBConfig) (*MongoDbUserHandler, error) {
|
||||
clientOptions := options.Client().ApplyURI(config.Url).SetAuth(options.Credential{
|
||||
Username: config.Username,
|
||||
Password: config.Password,
|
||||
|
||||
Reference in New Issue
Block a user