httpsecure

package module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

README

KrakenD HTTP Secure

A complete http security layer for the KakenD framework

This package is a wrapper over the github.com/unrolled/secure

Check the tests and the documentation for more details

Documentation

Index

Examples

Constants

View Source
const Namespace = "github_com/devopsfaith/krakend-httpsecure"

Namespace is the key to use to store and access the custom config data

Variables

View Source
var ZeroCfg = secure.Options{}

ZeroCfg is the zero value for the Config struct. Deprecated: the config getter does not return a ZeroCfg when no config available

Functions

func ConfigGetter

func ConfigGetter(e config.ExtraConfig) interface{}

ConfigGetter implements the config.ConfigGetter interface. It parses the extra config for the package and returns nil if something goes wrong.

Example
cfg := ConfigGetter(config.ExtraConfig{
	Namespace: map[string]interface{}{
		"allowed_hosts":      []interface{}{"host1"},
		"host_proxy_headers": []interface{}{"x-custom-header"},
		"sts_seconds":        10.0,
		"ssl_redirect":       true,
		"ssl_host":           "secure.example.com",
	},
})
fmt.Println(cfg)
Output:

{false false false false false false true false false false false       secure.example.com [host1] [x-custom-header] <nil> map[] 10 }
Example (FromParsedData)
sample := `{
            "allowed_hosts": ["host1"],
            "ssl_proxy_headers": {},
            "sts_seconds": 300,
            "frame_deny": true,
            "sts_include_subdomains": true
        }`
parsedCfg := map[string]interface{}{}

if err := json.Unmarshal([]byte(sample), &parsedCfg); err != nil {
	fmt.Println(err)
	return
}

cfg := ConfigGetter(config.ExtraConfig{Namespace: parsedCfg})
fmt.Println(cfg)
Output:

{false false false true false false false false false true false        [host1] [] <nil> map[] 300 }

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL