config

package
v0.0.0-...-9e2453e Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2019 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Database: DatabaseConfig{
		Type:         "mysql",
		Host:         "localhost",
		Port:         3306,
		User:         "gravitee_oauth2_server",
		Password:     "",
		DatabaseName: "gravitee_oauth2_server",
		MaxIdleConns: 5,
		MaxOpenConns: 5,
	},
	Oauth: OauthConfig{
		AccessTokenLifetime:  3600,
		RefreshTokenLifetime: 1209600,
		AuthCodeLifetime:     3600,
	},
	Session: SessionConfig{
		Secret:   "test_secret",
		Path:     "/",
		MaxAge:   86400 * 7,
		HTTPOnly: true,
	},
	IsDevelopment: true,
}

DefaultConfig ... Let's start with some sensible defaults

Functions

This section is empty.

Types

type Config

type Config struct {
	Database      DatabaseConfig
	Oauth         OauthConfig
	Session       SessionConfig
	ServerPort    int  `default:"8080"`
	IsDevelopment bool `default:"True"`
}

Config stores all configuration options

func NewConfig

func NewConfig(configFile string) *Config

NewConfig loads configuration from config file

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns *Config struct for testing purpose

type DatabaseConfig

type DatabaseConfig struct {
	Type         string `default:"mysql"`
	Host         string `default:"localhost"`
	Port         int    `default:"3306"`
	User         string `default:"gravitee"`
	Password     string `default:"gravitee"`
	DatabaseName string `default:"gravitee"`
	MaxIdleConns int    `default:"5"`
	MaxOpenConns int    `default:"5"`
}

DatabaseConfig stores database connection options

type OauthConfig

type OauthConfig struct {
	AccessTokenLifetime  int `default:"3600"`    // default to 1 hour
	RefreshTokenLifetime int `default:"1209600"` // default to 14 days
	AuthCodeLifetime     int `default:"3600"`    // default to 1 hour
}

OauthConfig stores oauth service configuration options

type SessionConfig

type SessionConfig struct {
	Secret string `default:"test_secret"`
	Path   string `default:"/"`
	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'.
	// MaxAge>0 means Max-Age attribute present and given in seconds.
	MaxAge int `default:"604800"`
	// When you tag a cookie with the HttpOnly flag, it tells the browser that
	// this particular cookie should only be accessed by the server.
	// Any attempt to access the cookie from client script is strictly forbidden.
	HTTPOnly bool `default:"True"`
}

SessionConfig stores session configuration for the web app

Jump to

Keyboard shortcuts

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