mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Create module for cluster IAM adapters
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
|||||||
apiclient "github.com/datarhei/core/v16/cluster/client"
|
apiclient "github.com/datarhei/core/v16/cluster/client"
|
||||||
"github.com/datarhei/core/v16/cluster/forwarder"
|
"github.com/datarhei/core/v16/cluster/forwarder"
|
||||||
clusteriam "github.com/datarhei/core/v16/cluster/iam"
|
clusteriam "github.com/datarhei/core/v16/cluster/iam"
|
||||||
|
clusteriamadapter "github.com/datarhei/core/v16/cluster/iam/adapter"
|
||||||
"github.com/datarhei/core/v16/cluster/proxy"
|
"github.com/datarhei/core/v16/cluster/proxy"
|
||||||
"github.com/datarhei/core/v16/cluster/raft"
|
"github.com/datarhei/core/v16/cluster/raft"
|
||||||
"github.com/datarhei/core/v16/cluster/store"
|
"github.com/datarhei/core/v16/cluster/store"
|
||||||
@@ -758,12 +759,12 @@ func (c *cluster) SetProcessMetadata(origin string, id app.ProcessID, key string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *cluster) IAM(superuser iamidentity.User, jwtRealm, jwtSecret string) (iam.IAM, error) {
|
func (c *cluster) IAM(superuser iamidentity.User, jwtRealm, jwtSecret string) (iam.IAM, error) {
|
||||||
policyAdapter, err := clusteriam.NewPolicyAdapter(c.store)
|
policyAdapter, err := clusteriamadapter.NewPolicyAdapter(c.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cluster policy adapter: %w", err)
|
return nil, fmt.Errorf("cluster policy adapter: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
identityAdapter, err := clusteriam.NewIdentityAdapter(c.store)
|
identityAdapter, err := clusteriamadapter.NewIdentityAdapter(c.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cluster identitry adapter: %w", err)
|
return nil, fmt.Errorf("cluster identitry adapter: %w", err)
|
||||||
}
|
}
|
||||||
|
28
cluster/iam/adapter/identity.go
Normal file
28
cluster/iam/adapter/identity.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package adapter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/datarhei/core/v16/cluster/store"
|
||||||
|
iamidentity "github.com/datarhei/core/v16/iam/identity"
|
||||||
|
)
|
||||||
|
|
||||||
|
type identityAdapter struct {
|
||||||
|
store store.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIdentityAdapter(store store.Store) (iamidentity.Adapter, error) {
|
||||||
|
a := &identityAdapter{
|
||||||
|
store: store,
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *identityAdapter) LoadIdentities() ([]iamidentity.User, error) {
|
||||||
|
users := a.store.UserList()
|
||||||
|
|
||||||
|
return users.Users, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *identityAdapter) SaveIdentities([]iamidentity.User) error {
|
||||||
|
return nil
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
package iam
|
package adapter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/datarhei/core/v16/cluster/store"
|
"github.com/datarhei/core/v16/cluster/store"
|
||||||
iamaccess "github.com/datarhei/core/v16/iam/access"
|
iamaccess "github.com/datarhei/core/v16/iam/access"
|
||||||
iamidentity "github.com/datarhei/core/v16/iam/identity"
|
|
||||||
|
|
||||||
"github.com/casbin/casbin/v2/model"
|
"github.com/casbin/casbin/v2/model"
|
||||||
)
|
)
|
||||||
@@ -101,25 +100,3 @@ func (a *policyAdapter) HasDomain(name string) bool {
|
|||||||
|
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
type identityAdapter struct {
|
|
||||||
store store.Store
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewIdentityAdapter(store store.Store) (iamidentity.Adapter, error) {
|
|
||||||
a := &identityAdapter{
|
|
||||||
store: store,
|
|
||||||
}
|
|
||||||
|
|
||||||
return a, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *identityAdapter) LoadIdentities() ([]iamidentity.User, error) {
|
|
||||||
users := a.store.UserList()
|
|
||||||
|
|
||||||
return users.Users, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *identityAdapter) SaveIdentities([]iamidentity.User) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
Reference in New Issue
Block a user