parent
d226bbe0f4
commit
1be5254b24
@ -0,0 +1,47 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name actor.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
Actor struct {
|
||||||
|
ID ActorID
|
||||||
|
State ActorState
|
||||||
|
Flags ActorFlags
|
||||||
|
|
||||||
|
CreatedBy ActorID
|
||||||
|
CreatedAt time.Time
|
||||||
|
ModifiedBy ActorID
|
||||||
|
ModifiedAt time.Time
|
||||||
|
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name d_role_manager.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac_i
|
||||||
|
|
||||||
|
import "brbac"
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
DRoleManager struct {
|
||||||
|
provider brbac.RoleProvider
|
||||||
|
repository brbac.RoleRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DRoleManagerFnc func (rm *DRoleManager) error
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func NewDRoleManager (provider brbac.RoleProvider, repository brbac.RoleRepository, ops ... DRoleManagerFnc) (*DRoleManager, error) {
|
||||||
|
rm := &DRoleManager {
|
||||||
|
provider : provider,
|
||||||
|
repository : repository,
|
||||||
|
}
|
||||||
|
for _,o := range ops {
|
||||||
|
if e:=o(rm); e!=nil {
|
||||||
|
return nil,e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rm,nil
|
||||||
|
}
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name d_role_provider.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac_i
|
||||||
|
|
||||||
|
import "brbac"
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
DRoleProvider struct {
|
||||||
|
repository brbac.RoleRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DRoleProviderFnc func(rp *DRoleProvider) error
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func NewDRoleProvider (repository brbac.RoleRepository, ops ...DRoleProviderFnc) (*DRoleProvider,error) {
|
||||||
|
rp := &DRoleProvider{
|
||||||
|
repository: repository,
|
||||||
|
}
|
||||||
|
for _,o := range ops {
|
||||||
|
if e := o(rp); e != nil {
|
||||||
|
return nil,e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rp,nil
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name d_role_repository.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac_i
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
DRoleRepository struct {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DRoleRepositoryFnc func (rr *DRoleRepository) error
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func NewDRoleRepository (ops ...DRoleRepositoryFnc) (*DRoleRepository,error) {
|
||||||
|
rr := &DRoleRepository{}
|
||||||
|
for _,o := range ops {
|
||||||
|
if e:=o(rr); e != nil {
|
||||||
|
return nil,e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rr,nil
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name d_user_manager.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac_i
|
||||||
|
|
||||||
|
import "brbac"
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
DUserManager struct {
|
||||||
|
provider brbac.UserProvider
|
||||||
|
repository brbac.UserRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DUserManagerFnc func (um *DUserManager) error
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewDUserManager (provider brbac.UserProvider, repository brbac.UserRepository, ops ... DUserManagerFnc) (*DUserManager, error) {
|
||||||
|
um := &DUserManager {
|
||||||
|
provider : provider,
|
||||||
|
repository : repository,
|
||||||
|
}
|
||||||
|
for _,o := range ops {
|
||||||
|
if e:=o(um); e!=nil {
|
||||||
|
return nil,e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return um,nil
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name d_user_provider.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac_i
|
||||||
|
|
||||||
|
import "brbac"
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
DUserProvider struct {
|
||||||
|
repository brbac.UserRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DUserProviderFnc func(rp *DUserProvider) error
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func NewDUserProvider (repository brbac.UserRepository, ops ...DUserProviderFnc) (*DUserProvider,error) {
|
||||||
|
rp := &DUserProvider{
|
||||||
|
repository: repository,
|
||||||
|
}
|
||||||
|
for _,o := range ops {
|
||||||
|
if e := o(rp); e != nil {
|
||||||
|
return nil,e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rp,nil
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name d_user_repository.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac_i
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
DUserRepository struct {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DUserRepositoryFnc func (rr *DUserRepository) error
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func NewDUserRepository (ops ...DUserRepositoryFnc) (*DUserRepository,error) {
|
||||||
|
rr := &DUserRepository{}
|
||||||
|
for _,o := range ops {
|
||||||
|
if e:=o(rr); e != nil {
|
||||||
|
return nil,e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rr,nil
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
module brbac_i
|
||||||
|
|
||||||
|
go 1.22
|
||||||
@ -0,0 +1,95 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name role_manager.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
import "rsls"
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
RoleManager interface {
|
||||||
|
|
||||||
|
Create () (*Role,error)
|
||||||
|
Update (role *Role) error
|
||||||
|
Delete (roleID ActorID) error
|
||||||
|
|
||||||
|
DelSubRole (roleID ...ActorID) error
|
||||||
|
AddSubRole (roleID ...ActorID) error
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func DetectRoleCycle(roleID, newRoleID ActorID, provider RoleProvider) rsls.RBool {
|
||||||
|
state := make(map[ActorID]byte)
|
||||||
|
return detectRoleCycle(roleID, newRoleID, provider, &state)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// detectRoleCycle realiza la verificación recursiva de si se forma un ciclo
|
||||||
|
func detectRoleCycle(roleID, newRoleID ActorID, provider RoleProvider, state *map[ActorID]byte) rsls.RBool {
|
||||||
|
|
||||||
|
// Si el nuevo rol ya está en la jerarquía del rol actual, entonces hemos encontrado un ciclo
|
||||||
|
if (*state)[newRoleID] == 1 {
|
||||||
|
return rsls.RBoolOkTrue // Ciclo detectado
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si el rol ha sido visitado completamente, entonces no es necesario revisarlo de nuevo
|
||||||
|
if (*state)[newRoleID] == 2 {
|
||||||
|
return rsls.RBoolOkFalse
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marcar el rol como "en proceso"
|
||||||
|
(*state)[newRoleID] = 1
|
||||||
|
|
||||||
|
// Obtener los subroles del nuevo rol
|
||||||
|
subRoles, err := provider.GetSubRoles(newRoleID)
|
||||||
|
if err != nil {
|
||||||
|
return rsls.MakeBoolError(err) // Error al obtener los subroles
|
||||||
|
}
|
||||||
|
|
||||||
|
// Realizar DFS para cada subrol del nuevo rol
|
||||||
|
for _, subRoleID := range subRoles {
|
||||||
|
if subRoleID == roleID {
|
||||||
|
// Detectar referencia directa al rol original, indicando un ciclo
|
||||||
|
return rsls.RBoolOkTrue
|
||||||
|
}
|
||||||
|
cycleCheck := detectRoleCycle(roleID, subRoleID, provider, state)
|
||||||
|
if !cycleCheck.IsOk() ||cycleCheck.Result() {
|
||||||
|
return cycleCheck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marcar el rol como "visitado" después de procesar todos sus subroles
|
||||||
|
(*state)[newRoleID] = 2
|
||||||
|
return rsls.RBoolOkFalse // No se ha detectado un ciclo
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name role_repository.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
RoleRepository interface {
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name roles.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
|
type Roles []ActorID
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name session.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 10/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
Session interface {
|
||||||
|
|
||||||
|
Principal () *User
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name session_manager.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 10/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name session_provider.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 10/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name session_repository.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 10/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name user.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
User struct {
|
||||||
|
Actor
|
||||||
|
roles Roles
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name user_manager.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
UserManager interface {
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name user_provider.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
UserProvider interface {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name user_repository.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package brbac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
|
||||||
|
UserRepository interface {
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name r_bool_error.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package rsls
|
||||||
|
|
||||||
|
|
||||||
|
type (
|
||||||
|
|
||||||
|
RBoolError struct {
|
||||||
|
error
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func MakeBoolError (err error) RBoolError {
|
||||||
|
return RBoolError{err } }
|
||||||
|
|
||||||
|
|
||||||
|
func (_ RBoolError) IsOk () bool {
|
||||||
|
return false }
|
||||||
|
|
||||||
|
func (_ RBoolError) Result() bool {
|
||||||
|
return false }
|
||||||
|
|
||||||
|
func (s RBoolError) Fail () error {
|
||||||
|
return s.error }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name r_bool_ok.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 09/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package rsls
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const (
|
||||||
|
RBoolOkTrue RBoolOk = true
|
||||||
|
RBoolOkFalse RBoolOk = false
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type RBoolOk bool
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func (_ RBoolOk) IsOk () bool {
|
||||||
|
return true }
|
||||||
|
|
||||||
|
func (s RBoolOk) Result() bool {
|
||||||
|
return bool(s) }
|
||||||
|
|
||||||
|
func (_ RBoolOk) Fail () error {
|
||||||
|
return nil }
|
||||||
|
|
||||||
@ -0,0 +1,196 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name active.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 11/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package vigil
|
||||||
|
|
||||||
|
import "errs"
|
||||||
|
|
||||||
|
var (
|
||||||
|
|
||||||
|
// G Public vars
|
||||||
|
G = struct {
|
||||||
|
ErrInvalidActor errs.ErrCode
|
||||||
|
} {
|
||||||
|
ErrInvalidActor : errs.ErrCode("invalid-actor-type"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// g Private vars
|
||||||
|
g = struct {
|
||||||
|
actorFlags []ActorStateFlags
|
||||||
|
actorFlagNames []string
|
||||||
|
|
||||||
|
actorModeNames []string
|
||||||
|
|
||||||
|
actorTypeAtts []ActorTypeAtts
|
||||||
|
actorTypeNames []string
|
||||||
|
}{
|
||||||
|
|
||||||
|
actorFlags: []ActorStateFlags{
|
||||||
|
ActorFlagVerified,
|
||||||
|
ActorFlagRequired,
|
||||||
|
ActorFlagRestricted,
|
||||||
|
ActorFlagLimited,
|
||||||
|
ActorFlagCompromised,
|
||||||
|
},
|
||||||
|
|
||||||
|
actorFlagNames: []string {
|
||||||
|
"Verified",
|
||||||
|
"Required",
|
||||||
|
"Restricted",
|
||||||
|
"Limited",
|
||||||
|
"Compromised",
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
actorModeNames: []string{
|
||||||
|
"Active",
|
||||||
|
"Inactive",
|
||||||
|
"Pending",
|
||||||
|
"Suspended ",
|
||||||
|
"Revoked",
|
||||||
|
"Paused",
|
||||||
|
"Expired",
|
||||||
|
"Deleted",
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
actorTypeNames: []string{
|
||||||
|
"User", // 0x00
|
||||||
|
"Role", // 0x01
|
||||||
|
"Service", // 0x02
|
||||||
|
"Device", // 0x03
|
||||||
|
"Group", // 0x04
|
||||||
|
"Organization", // 0x05
|
||||||
|
"APIKey", // 0x06
|
||||||
|
"System", // 0x07
|
||||||
|
"Admin", // 0x08
|
||||||
|
"Visitor", // 0x09
|
||||||
|
"Auditor", // 0x0A
|
||||||
|
"ExternalClient", // 0x0B
|
||||||
|
"Provider", // 0x0C
|
||||||
|
"TemporaryToken", // 0x0D
|
||||||
|
"Bot", // 0x0E
|
||||||
|
"Reserved", // 0x0F
|
||||||
|
"BlockchainNode", // 0x10
|
||||||
|
"BlockchainUser", // 0x11
|
||||||
|
"SmartContract", // 0x12
|
||||||
|
"BlockchainAPI", // 0x13
|
||||||
|
"Wallet", // 0x14
|
||||||
|
"Miner", // 0x15
|
||||||
|
"Validator", // 0x16
|
||||||
|
"DApp", // 0x17
|
||||||
|
"Token", // 0x18
|
||||||
|
"BlockchainOracle", // 0x19
|
||||||
|
"BlockchainExplorer", // 0x1A
|
||||||
|
"DAO", // 0x1B
|
||||||
|
"NFT", // 0x1C
|
||||||
|
"BlockchainBridge", // 0x1D
|
||||||
|
"Staking", // 0x1E
|
||||||
|
"DefiPlatform", // 0x1F
|
||||||
|
"BlockchainWallet", // 0x20
|
||||||
|
"BlockchainExplorerAPI", // 0x21
|
||||||
|
"BlockchainTransaction", // 0x22
|
||||||
|
"BlockchainBackup", // 0x23
|
||||||
|
"SecurityModule", // 0x24
|
||||||
|
"QuantumComputer", // 0x25
|
||||||
|
"QuantumWallet", // 0x26
|
||||||
|
"AI", // 0x30
|
||||||
|
"CloudService", // 0x31
|
||||||
|
"Microservice", // 0x32
|
||||||
|
"ThirdParty", // 0x33
|
||||||
|
"ExternalSystem", // 0x34
|
||||||
|
"MobileDevice", // 0x35
|
||||||
|
"ExternalAPI", // 0x36
|
||||||
|
"Server", // 0x37
|
||||||
|
"UserAgent", // 0x38
|
||||||
|
"Container", // 0x39
|
||||||
|
"Network", // 0x3A
|
||||||
|
"EdgeDevice", // 0x3B
|
||||||
|
"VirtualMachine", // 0x3C
|
||||||
|
"Hypervisor", // 0x3D
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
actorTypeAtts: []ActorTypeAtts {
|
||||||
|
ActorTypeAttCanLogin | ActorTypeAttExclusive, // User", 0x00
|
||||||
|
0, // Role", 0x01
|
||||||
|
0, // Service", 0x02
|
||||||
|
0, // Device", 0x03
|
||||||
|
0, // Group", 0x04
|
||||||
|
0, // Organization", 0x05
|
||||||
|
0, // APIKey", 0x06
|
||||||
|
0, // System", 0x07
|
||||||
|
0, // Admin", 0x08
|
||||||
|
0, // Visitor", 0x09
|
||||||
|
0, // Auditor", 0x0A
|
||||||
|
0, // ExternalClient", 0x0B
|
||||||
|
0, // Provider", 0x0C
|
||||||
|
0, // TemporaryToken", 0x0D
|
||||||
|
0, // Bot", 0x0E
|
||||||
|
0, // Reserved", 0x0F
|
||||||
|
0, // BlockchainNode", 0x10
|
||||||
|
0, // BlockchainUser", 0x11
|
||||||
|
0, // SmartContract", 0x12
|
||||||
|
0, // BlockchainAPI", 0x13
|
||||||
|
0, // Wallet", 0x14
|
||||||
|
0, // Miner", 0x15
|
||||||
|
0, // Validator", 0x16
|
||||||
|
0, // DApp", 0x17
|
||||||
|
0, // Token", 0x18
|
||||||
|
0, // BlockchainOracle", 0x19
|
||||||
|
0, // BlockchainExplorer", 0x1A
|
||||||
|
0, // DAO", 0x1B
|
||||||
|
0, // NFT", 0x1C
|
||||||
|
0, // BlockchainBridge", 0x1D
|
||||||
|
0, // Staking", 0x1E
|
||||||
|
0, // DefiPlatform", 0x1F
|
||||||
|
0, // BlockchainWallet", 0x20
|
||||||
|
0, // BlockchainExplorerAPI", 0x21
|
||||||
|
0, // BlockchainTransaction", 0x22
|
||||||
|
0, // BlockchainBackup", 0x23
|
||||||
|
0, // SecurityModule", 0x24
|
||||||
|
0, // QuantumComputer", 0x25
|
||||||
|
0, // QuantumWallet", 0x26
|
||||||
|
0, // AI", 0x30
|
||||||
|
0, // CloudService", 0x31
|
||||||
|
0, // Microservice", 0x32
|
||||||
|
0, // ThirdParty", 0x33
|
||||||
|
0, // ExternalSystem", 0x34
|
||||||
|
0, // MobileDevice", 0x35
|
||||||
|
0, // ExternalAPI", 0x36
|
||||||
|
0, // Server", 0x37
|
||||||
|
0, // UserAgent", 0x38
|
||||||
|
0, // Container", 0x39
|
||||||
|
0, // Network", 0x3A
|
||||||
|
0, // EdgeDevice", 0x3B
|
||||||
|
0, // VirtualMachine", 0x3C
|
||||||
|
0, // Hypervisor", 0x3D
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name actor_id.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 11/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package vigil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type ActorID uint64
|
||||||
|
|
||||||
|
|
||||||
|
// GetActorType extrae los 6 bits más significativos para determinar el tipo de Actor.
|
||||||
|
func (a ActorID) GetActorType() ActorType {
|
||||||
|
// Desplazar el ActorID 58 bits a la derecha para que los 6 bits más significativos estén al inicio,
|
||||||
|
// y luego convertirlos en un ActorType.
|
||||||
|
return ActorType(a >> 58) // Extraemos los 6 bits más significativos
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// SetActorType establece los 6 bits más significativos como el tipo de Actor.
|
||||||
|
func (a ActorID) SetActorType(actorType ActorType) ActorID {
|
||||||
|
// Verificar que el tipo está dentro del rango de 6 bits (0-63).
|
||||||
|
if actorType > 0x3F { // 0x3F es 63 en decimal, el rango de 6 bits
|
||||||
|
panic(G.ErrInvalidActor)
|
||||||
|
}
|
||||||
|
// Establecer el nuevo tipo en los 6 bits más significativos.
|
||||||
|
return ActorID((a &^ (ActorID(0x3F) << 58)) | (ActorID(actorType) << 58))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name actor_mode.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 11/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package vigil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Modo (primeros 4 bits)
|
||||||
|
ActorModeActive ActorMode = 0b000 // El usuario está activo y no tiene restricciones
|
||||||
|
ActorModeInactive ActorMode = 0b001 // El usuario está inactivo y temporalmente deshabilitado
|
||||||
|
ActorModePending ActorMode = 0b010 // El usuario está pendiente de activación (por ejemplo, verificación de correo electrónico)
|
||||||
|
ActorModeSuspended ActorMode = 0b011 // El usuario está suspendido debido a problemas de seguridad o políticas
|
||||||
|
ActorModeRevoked ActorMode = 0b100 // El acceso del usuario ha sido revocado permanentemente
|
||||||
|
ActorModePaused ActorMode = 0b101 // El usuario ha pausado su cuenta (puede reactivarse)
|
||||||
|
ActorModeExpired ActorMode = 0b110 // La cuenta del usuario ha expirado (por ejemplo, acceso temporal)
|
||||||
|
ActorModeDeleted ActorMode = 0b111 // La cuenta del usuario está eliminada y ya no existe
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type ActorMode uint8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name actor_state.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 11/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package vigil
|
||||||
|
|
||||||
|
import "math/bits"
|
||||||
|
|
||||||
|
|
||||||
|
const (
|
||||||
|
modeBits = 4
|
||||||
|
modeMask ActorState = 0b1111
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type ActorState uint16
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func (s ActorState) GetMode() ActorMode {
|
||||||
|
return ActorMode(s & modeMask) }
|
||||||
|
|
||||||
|
func (s ActorState) SetMode(state ActorMode) ActorState {
|
||||||
|
return (s &^ modeMask) | (ActorState(state) & modeMask) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func (s ActorState) HasFlag (flag ActorStateFlags) bool {
|
||||||
|
return s & ActorState(flag) != 0 }
|
||||||
|
|
||||||
|
func (s ActorState) SetFlag (flag ActorStateFlags) ActorState {
|
||||||
|
return (s &^ modeMask) | ((s | ActorState(flag)) &^ modeMask) }
|
||||||
|
|
||||||
|
func (s ActorState) DelFlag (flag ActorStateFlags) ActorState {
|
||||||
|
return (s &^ modeMask) | ((s &^ ActorState(flag)) &^ modeMask) }
|
||||||
|
|
||||||
|
func (s ActorState) ClearFlags () ActorState {
|
||||||
|
return s & modeMask }
|
||||||
|
|
||||||
|
|
||||||
|
func (s ActorState) Count() int {
|
||||||
|
return bits.OnesCount16(uint16(s) >> modeBits) }
|
||||||
|
|
||||||
|
func (s ActorState) Flags() []ActorStateFlags {
|
||||||
|
var flags []ActorStateFlags
|
||||||
|
for _, flag := range g.actorFlags {
|
||||||
|
if s.HasFlag(flag) {
|
||||||
|
flags = append(flags, flag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flags
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name actor_state_flags.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 11/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package vigil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Flags (últimos 16 - modeBits )
|
||||||
|
_ ActorStateFlags = iota
|
||||||
|
ActorFlagVerified ActorStateFlags = 1 << (modeBits + iota - 1)
|
||||||
|
ActorFlagRequired
|
||||||
|
ActorFlagRestricted
|
||||||
|
ActorFlagLimited
|
||||||
|
ActorFlagCompromised
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type ActorStateFlags uint16
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name actor_type.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 11/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package vigil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Definición de los valores posibles para ActorType (64 tipos con 8 bits).
|
||||||
|
const (
|
||||||
|
// Tipos Generales
|
||||||
|
ActorTypeUser ActorType = iota
|
||||||
|
ActorTypeRole // Rol
|
||||||
|
ActorTypeService // Servicio
|
||||||
|
ActorTypeDevice // Dispositivo (IoT, hardware)
|
||||||
|
ActorTypeGroup // Grupo
|
||||||
|
ActorTypeOrganization // Organización
|
||||||
|
ActorTypeAPIKey // API Key
|
||||||
|
ActorTypeSystem // Sistema interno
|
||||||
|
ActorTypeAdmin // Administrador
|
||||||
|
ActorTypeVisitor // Visitante
|
||||||
|
ActorTypeAuditor // Auditor
|
||||||
|
ActorTypeExternalClient // Cliente Externo
|
||||||
|
ActorTypeProvider // Proveedor
|
||||||
|
ActorTypeTemporaryToken // Token Temporal
|
||||||
|
ActorTypeBot // Bot o script
|
||||||
|
ActorTypeReserved // Reservado para futuras expansiones
|
||||||
|
|
||||||
|
// Tipos Relacionados con Blockc
|
||||||
|
ActorTypeBlockchainNode // Nodo de blockchain
|
||||||
|
ActorTypeBlockchainUser // Usuario de blockchain
|
||||||
|
ActorTypeSmartContract // Contrato inteligente (smart contract)
|
||||||
|
ActorTypeBlockchainAPI // API de blockchain
|
||||||
|
ActorTypeWallet // Billetera (wallet) de blockchain
|
||||||
|
ActorTypeMiner // Minero de blockchain
|
||||||
|
ActorTypeValidator // Validador de transacciones o bloques
|
||||||
|
ActorTypeDApp // Aplicación descentralizada (DApp)
|
||||||
|
ActorTypeToken // Token o criptomoneda
|
||||||
|
ActorTypeBlockchainOracle // Oráculo de blockchain (proveedor de datos externos)
|
||||||
|
ActorTypeBlockchainExplorer // Explorador de blockchain
|
||||||
|
ActorTypeDAO // Organización Autónoma Descentralizada (DAO)
|
||||||
|
ActorTypeNFT // Token No Fungible (NFT)
|
||||||
|
ActorTypeBlockchainBridge // Puente entre blockchains
|
||||||
|
ActorTypeStaking // Participante en staking
|
||||||
|
ActorTypeDefiPlatform // Plataforma de Finanzas Descentralizadas (DeFi)
|
||||||
|
ActorTypeBlockchainWallet // Billetera específica de blockchain
|
||||||
|
ActorTypeBlockchainExplorerAPI // API para exploradores de blockchain
|
||||||
|
ActorTypeBlockchainTransaction // Transacción de blockchain
|
||||||
|
ActorTypeBlockchainBackup // Copia de seguridad o servicio de respaldo de blockchain
|
||||||
|
ActorTypeSecurityModule // Módulo de seguridad de blockchain
|
||||||
|
ActorTypeQuantumComputer // Computadora cuántica (relacionada con blockchain)
|
||||||
|
ActorTypeQuantumWallet // Billetera cuántica (relacionada con blockchain)
|
||||||
|
|
||||||
|
// Otros Tipos
|
||||||
|
ActorTypeAI // Actor basado en inteligencia artificial
|
||||||
|
ActorTypeCloudService // Servicio en la nube
|
||||||
|
ActorTypeMicroservice // Microservicio
|
||||||
|
ActorTypeThirdParty // Actor externo o tercero
|
||||||
|
ActorTypeExternalSystem // Sistema Externo
|
||||||
|
ActorTypeMobileDevice // Dispositivo móvil
|
||||||
|
ActorTypeExternalAPI // API externa
|
||||||
|
ActorTypeServer // Servidor físico o virtual
|
||||||
|
ActorTypeUserAgent // Agente de usuario (navegador, app, etc.)
|
||||||
|
ActorTypeContainer // Contenedor (Docker, etc.)
|
||||||
|
ActorTypeNetwork // Red o infraestructura de red
|
||||||
|
ActorTypeEdgeDevice // Dispositivo en la periferia de la red
|
||||||
|
ActorTypeVirtualMachine // Máquina virtual
|
||||||
|
ActorTypeHypervisor // Hypervisor o administrador de máquinas virtuales
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type ActorType uint8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func (a ActorType) Name () string {
|
||||||
|
i := int(a)
|
||||||
|
if i < len(g.actorTypeNames) {
|
||||||
|
return g.actorTypeNames[i]
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// 🚀 Project Active8
|
||||||
|
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||||
|
//
|
||||||
|
// File name actor_type_atts.go
|
||||||
|
// ✍️ Created by DEV
|
||||||
|
// 📅 Modified 11/12/2024
|
||||||
|
//
|
||||||
|
// 🔒 Copyright 2024 activething.com
|
||||||
|
//
|
||||||
|
// 📜 LICENSE --------------------------------------------------------------
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package vigil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const (
|
||||||
|
|
||||||
|
ActorTypeAttCanLogin ActorTypeAtts =1 << iota
|
||||||
|
ActorTypeAttExclusive
|
||||||
|
ActorTypeAttSameTypes
|
||||||
|
ActorTypeAttNotSameTypes
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type ActorTypeAtts uint8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
module vigil
|
||||||
|
|
||||||
|
go 1.22
|
||||||
Loading…
Reference in new issue