Skip to content
Snippets Groups Projects
Select Git revision
  • 98869b53fbd27c1fe19cd290b0d5c79189893f76
  • master default protected
  • renovate/bootstrap-5.x
  • renovate/purgecss-webpack-plugin-7.x
  • renovate/mini-css-extract-plugin-2.x
  • renovate/html-webpack-plugin-5.x
  • renovate/golang-1.x
  • renovate/css-loader-6.x
8 results

main.go

    • ale's avatar
      0def9013
      Switch to a self-hosted binary, add graph-related code · 0def9013
      ale authored
      The app is now self-hosted instead of relying on the static-content
      standalone server, so we can eventually add dynamic code for graph
      serving.
      
      The static content serving has improved, with more consistent cache
      header management, as well as the capability of serving pre-compressed
      content.
      
      Additional code to implement the generation of dependency (flow)
      graphs in dot format was added (not hooked to the HTTP server yet).
      0def9013
      History
      Switch to a self-hosted binary, add graph-related code
      ale authored
      The app is now self-hosted instead of relying on the static-content
      standalone server, so we can eventually add dynamic code for graph
      serving.
      
      The static content serving has improved, with more consistent cache
      header management, as well as the capability of serving pre-compressed
      content.
      
      Additional code to implement the generation of dependency (flow)
      graphs in dot format was added (not hooked to the HTTP server yet).
    main.go 1.16 KiB
    package main
    
    import (
    	"flag"
    	"io/ioutil"
    	"log"
    
    	"git.autistici.org/ai3/go-common/serverutil"
    	"gopkg.in/yaml.v2"
    
    	"git.autistici.org/id/go-sso/saml"
    )
    
    var (
    	addr       = flag.String("addr", ":5007", "address to listen on")
    	configFile = flag.String("config", "/etc/sso/saml.yml", "`path` of config file")
    )
    
    // Config wraps together the standard HTTP server config and the SAML
    // service configuration.
    type Config struct {
    	SAMLConfig   *saml.Config             `yaml:"saml"`
    	ServerConfig *serverutil.ServerConfig `yaml:"http_server"`
    }
    
    func loadConfig() (*Config, error) {
    	// Read YAML config.
    	data, err := ioutil.ReadFile(*configFile)
    	if err != nil {
    		return nil, err
    	}
    	var config Config
    	if err := yaml.Unmarshal(data, &config); err != nil {
    		return nil, err
    	}
    	return &config, nil
    }
    
    func main() {
    	log.SetFlags(0)
    	flag.Parse()
    
    	config, err := loadConfig()
    	if err != nil {
    		log.Fatalf("error loading configuration: %v", err)
    	}
    
    	s, err := saml.NewSAMLIDP(config.SAMLConfig)
    	if err != nil {
    		log.Fatalf("error instantiating SAML IDP: %v", err)
    	}
    
    	if err := serverutil.Serve(s, config.ServerConfig, *addr); err != nil {
    		log.Fatalf("error: %v", err)
    	}
    }