2 * Handle fbfp's configuration.
4 * Copyright (C) 2024 Runxi Yu <https://runxiyu.org>
5 * SPDX-License-Identifier: AGPL-3.0-or-later
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 "git.sr.ht/~emersion/go-scfg"
31 * config.Openid.Authorize doesn't have to be specified. But if it is
32 * specified, it replaces the once obtained from the
33 * .well-known/openid-configuration endpoint. Because Microsoft doesn't seem to
34 * want to put their v2.0 authorization endpoint anywhere in their
38 var config_with_pointers
struct {
39 Url
*string `scfg:"url"`
40 Prod
*bool `scfg:"prod"`
41 Tmpl
*string `scfg:"tmpl"`
42 Static
*bool `scfg:"static"`
44 Addr
*string `scfg:"addr"`
45 Net
*string `scfg:"net"`
46 Proto
*string `scfg:"proto"`
49 Type
*string `scfg:"type"`
50 Conn
*string `scfg:"conn"`
53 Client
*string `scfg:"client"`
54 Endpoint
*string `scfg:"endpoint"`
55 Authorize
*string `scfg:"authorize"`
80 func fbfp_get_config(path
string) error
{
81 f
:= er(os
.Open(path
))
83 err
:= scfg
.NewDecoder(bufio
.NewReader(f
)).Decode(&config_with_pointers
)
89 * TODO: We segfault when there are missing configuration options.
90 * There should be better ways to handle this.
92 config
.Url
= *(config_with_pointers
.Url
)
93 config
.Prod
= *(config_with_pointers
.Prod
)
94 config
.Tmpl
= *(config_with_pointers
.Tmpl
)
95 config
.Static
= *(config_with_pointers
.Static
)
96 config
.Listen
.Addr
= *(config_with_pointers
.Listen
.Addr
)
97 config
.Listen
.Net
= *(config_with_pointers
.Listen
.Net
)
98 config
.Listen
.Proto
= *(config_with_pointers
.Listen
.Proto
)
99 config
.Db
.Type
= *(config_with_pointers
.Db
.Type
)
100 config
.Db
.Conn
= *(config_with_pointers
.Db
.Conn
)
101 config
.Openid
.Client
= *(config_with_pointers
.Openid
.Client
)
102 config
.Openid
.Endpoint
= *(config_with_pointers
.Openid
.Endpoint
)
104 if config_with_pointers
.Openid
.Authorize
!= nil {
105 config
.Openid
.Authorize
=
106 *(config_with_pointers
.Openid
.Authorize
)