38 lines
886 B
Go
38 lines
886 B
Go
package network
|
|
|
|
import (
|
|
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/authn"
|
|
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
|
"github.com/mitchellh/mapstructure"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type LayerOptions struct {
|
|
authn.LayerOptions
|
|
AuthorizedCIDRs []string `mapstructure:"authorizedCIDRs"`
|
|
TemplateBlock string `mapstructure:"templateBlock"`
|
|
}
|
|
|
|
func fromStoreOptions(storeOptions store.LayerOptions) (*LayerOptions, error) {
|
|
layerOptions := LayerOptions{
|
|
LayerOptions: authn.DefaultLayerOptions(),
|
|
AuthorizedCIDRs: []string{},
|
|
TemplateBlock: "default",
|
|
}
|
|
|
|
config := mapstructure.DecoderConfig{
|
|
Result: &layerOptions,
|
|
}
|
|
|
|
decoder, err := mapstructure.NewDecoder(&config)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := decoder.Decode(storeOptions); err != nil {
|
|
return nil, errors.WithStack(err)
|
|
}
|
|
|
|
return &layerOptions, nil
|
|
}
|