Formatting
[fbfp.git] / config.go
blob4e582c034047bff6d25b16158dddb8ee3de4e34c
1 package main
3 import (
4 "bufio"
5 "os"
7 "git.sr.ht/~emersion/go-scfg"
11 * config.Openid.Authorize doesn't have to be specified. But if it is
12 * specified, it replaces the once obtained from the
13 * .well-known/openid-configuration endpoint. Because Microsoft doesn't seem to
14 * want to put their v2.0 authorization endpoint anywhere in their
15 * configuration.
18 var config_with_pointers struct {
19 Listen *string `scfg:"listen"`
20 Url *string `scfg:"url"`
21 Openid struct {
22 Client *string `scfg:"client"`
23 Secret *string `scfg:"secret"`
24 Endpoint *string `scfg:"endpoint"`
25 Authorize *string `scfg:"authorize"`
26 Redirect *string `scfg:"redirect"`
27 } `scfg:"openid"`
30 var config struct {
31 Listen string
32 Url string
33 Openid struct {
34 Client string
35 Secret string
36 Endpoint string
37 Authorize string
38 Redirect string
42 func fbfp_get_config(path string) {
43 f, err := os.Open(path)
44 e(err)
46 err = scfg.NewDecoder(bufio.NewReader(f)).Decode(&config_with_pointers)
47 e(err)
50 * TODO: We segfault when there are missing configuration options.
51 * There should be better ways to handle this.
53 config.Listen = *(config_with_pointers.Listen)
54 config.Url = *(config_with_pointers.Url)
55 config.Openid.Client = *(config_with_pointers.Openid.Client)
56 config.Openid.Endpoint = *(config_with_pointers.Openid.Endpoint)
57 config.Openid.Secret = *(config_with_pointers.Openid.Secret)
58 config.Openid.Redirect = *(config_with_pointers.Openid.Redirect)
60 if config_with_pointers.Openid.Authorize != nil {
61 config.Openid.Authorize = *(config_with_pointers.Openid.Authorize)