feat: new openid connect authentication layer
Some checks are pending
Cadoles/bouncer/pipeline/pr-develop Build started...
Some checks are pending
Cadoles/bouncer/pipeline/pr-develop Build started...
This commit is contained in:
39
internal/schema/extend.go
Normal file
39
internal/schema/extend.go
Normal file
@ -0,0 +1,39 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func Extend(base []byte, schema []byte) ([]byte, error) {
|
||||
var (
|
||||
extension map[string]any
|
||||
extended map[string]any
|
||||
)
|
||||
|
||||
if err := json.Unmarshal(base, &extended); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(schema, &extension); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
extended["$id"] = extension["$id"]
|
||||
extended["title"] = extension["title"]
|
||||
|
||||
props := extension["properties"].(map[string]any)
|
||||
extendedProps := extended["properties"].(map[string]any)
|
||||
for key, val := range props {
|
||||
extendedProps[key] = val
|
||||
}
|
||||
extended["properties"] = extendedProps
|
||||
|
||||
data, err := json.MarshalIndent(extended, "", " ")
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
Reference in New Issue
Block a user