Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
98711636
Commit
98711636
authored
6 years ago
by
Roshan Patil
Browse files
Options
Downloads
Patches
Plain Diff
Global Config + Casbin Roleenforcer for SLS
parent
dcdf98e1
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!61
Global Config + Casbin Roleenforcer for SLS
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
authmdl/roleenforcemdl/roleenforcement.go
+15
-0
authmdl/roleenforcemdl/roleenforcement.go
constantmdl/constantmdl.go
+2
-0
constantmdl/constantmdl.go
servicebuildermdl/servicebuildermdl.go
+47
-0
servicebuildermdl/servicebuildermdl.go
with
64 additions
and
0 deletions
authmdl/roleenforcemdl/roleenforcement.go
+
15
−
0
View file @
98711636
...
...
@@ -59,6 +59,21 @@ func LoadRoleConfiguration(csvFilePath string) {
})
}
// RegisterUser - RegisterUser register use
func
RegisterUser
(
group
,
URL
string
,
isAllowed
bool
)
{
roleObject
,
ok
:=
roleManagementConfig
[
URL
]
if
ok
{
roleObject
=
assignURL
(
group
,
isAllowed
,
roleObject
)
}
else
{
roleObject
=
URLGroupMapping
{
Allowed
:
make
(
map
[
string
]
bool
),
NotAllowed
:
make
(
map
[
string
]
bool
),
}
roleObject
=
assignURL
(
group
,
isAllowed
,
roleObject
)
}
roleManagementConfig
[
URL
]
=
roleObject
}
func
registerUser
(
group
,
URL
string
,
isAllowed
bool
)
{
roleObject
,
ok
:=
roleManagementConfig
[
URL
]
if
ok
{
...
...
This diff is collapsed.
Click to expand it.
constantmdl/constantmdl.go
+
2
−
0
View file @
98711636
...
...
@@ -61,3 +61,5 @@ const (
const
MIME
=
"MIME-version: 1.0;
\n
Content-Type: text/html; charset=
\"
UTF-8
\"
;
\n\n
"
const
COUNTRYCODE
=
"91"
const
MQLRequestData
=
"MQLRequestData"
This diff is collapsed.
Click to expand it.
servicebuildermdl/servicebuildermdl.go
+
47
−
0
View file @
98711636
...
...
@@ -9,6 +9,8 @@ import (
"sync"
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/constantmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/validationmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
...
...
@@ -18,11 +20,15 @@ import (
"github.com/tidwall/gjson"
)
var
globalConfig
map
[
string
]
string
var
once
sync
.
Once
var
ruleCache
map
[
string
]
conditions
.
Expr
var
mutex
=
&
sync
.
Mutex
{}
func
init
()
{
ruleCache
=
make
(
map
[
string
]
conditions
.
Expr
)
globalConfig
=
make
(
map
[
string
]
string
)
}
// LoadData is a method sign for loader methods
...
...
@@ -35,6 +41,16 @@ type FinalStepProcessOutput = func(ab *AbstractBusinessLogicHolder) (*interface{
type
AbstractBusinessLogicHolder
struct
{
localServiceData
map
[
string
]
interface
{}
pricipalObject
Principal
globalConfigData
map
[
string
]
string
}
// SetGlobalConfig - SetGlobalConfig
func
SetGlobalConfig
(
configs
map
[
string
]
string
)
{
once
.
Do
(
func
()
{
if
configs
!=
nil
{
globalConfig
=
configs
}
})
}
// GetDataString will give you string
...
...
@@ -94,6 +110,22 @@ func (ab *AbstractBusinessLogicHolder) GetDataResultset(key string) (*gjson.Resu
return
value
,
true
}
func
(
ab
*
AbstractBusinessLogicHolder
)
GetMQLRequestData
()
(
*
gjson
.
Result
,
bool
)
{
//check in map
temp
,
found
:=
ab
.
localServiceData
[
constantmdl
.
MQLRequestData
]
if
errormdl
.
CheckBool
(
!
found
)
{
loggermdl
.
LogWarn
(
"MQL Request Data not Found"
)
return
&
gjson
.
Result
{},
false
}
// cast it
value
,
ok
:=
temp
.
(
*
gjson
.
Result
)
if
errormdl
.
CheckBool1
(
!
ok
)
{
return
&
gjson
.
Result
{},
false
}
return
value
,
true
}
// GetDataBool will give you int
func
(
ab
*
AbstractBusinessLogicHolder
)
GetDataBool
(
key
string
)
(
bool
,
bool
)
{
//check in map
...
...
@@ -120,9 +152,19 @@ func (ab *AbstractBusinessLogicHolder) GetCustomData(key string) (interface{}, b
return
temp
,
true
}
// GetGlobalConfigString - return string value for global config key
func
(
ab
*
AbstractBusinessLogicHolder
)
GetGlobalConfigString
(
key
string
)
(
string
,
bool
)
{
value
,
found
:=
ab
.
globalConfigData
[
key
]
if
errormdl
.
CheckBool
(
!
found
)
{
return
""
,
false
}
return
value
,
true
}
// New will create memory for your data
func
(
ab
*
AbstractBusinessLogicHolder
)
New
(
principalObject
*
Principal
)
*
AbstractBusinessLogicHolder
{
ab
.
localServiceData
=
make
(
map
[
string
]
interface
{})
ab
.
globalConfigData
=
globalConfig
ab
.
pricipalObject
=
*
principalObject
return
ab
}
...
...
@@ -132,6 +174,11 @@ func (ab *AbstractBusinessLogicHolder) SetResultset(key string, obj *gjson.Resul
ab
.
localServiceData
[
key
]
=
obj
}
// SetMQLRequestData - set value
func
(
ab
*
AbstractBusinessLogicHolder
)
SetMQLRequestData
(
obj
*
gjson
.
Result
)
{
ab
.
localServiceData
[
constantmdl
.
MQLRequestData
]
=
obj
}
// SetByteData will set byte data as gjson.Result
func
(
ab
*
AbstractBusinessLogicHolder
)
SetByteData
(
key
string
,
obj
[]
byte
)
{
rs
:=
gjson
.
ParseBytes
(
obj
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets