This commit is contained in:
Daniel Ponte 2022-09-26 15:00:21 -04:00
parent d474112fd2
commit efd920cb04
7 changed files with 35 additions and 21 deletions

View file

@ -1,14 +1,12 @@
package bus package bus
import ( import ()
)
type Bus struct { type Bus struct {
} }
func New() *Bus { func New() *Bus {
bus := &Bus{ bus := &Bus{}
}
return bus return bus
} }

View file

@ -15,9 +15,9 @@ type ServeOptions struct {
func Command(cfg *config.Config) *cobra.Command { func Command(cfg *config.Config) *cobra.Command {
opts := makeOptions(cfg) opts := makeOptions(cfg)
serveCmd := &cobra.Command{ serveCmd := &cobra.Command{
Use: "serve", Use: "serve",
Short: "starts the " + common.AppName + " server", Short: "starts the " + common.AppName + " server",
RunE: common.RunE(opts), RunE: common.RunE(opts),
} }
return serveCmd return serveCmd

View file

@ -16,11 +16,11 @@ type Config struct {
} }
const ( const (
IncludeTag = "!include" IncludeTag = "!include"
IncludeDirNamedTag = "!include_dir_named" IncludeDirNamedTag = "!include_dir_named"
IncludeDirListTag = "!include_dir_list" IncludeDirListTag = "!include_dir_list"
IncludeDirMergeNamedTag = "!include_dir_merge_named" IncludeDirMergeNamedTag = "!include_dir_merge_named"
SecretTag = "!secret" SecretTag = "!secret"
) )
func (c *Config) UnmarshalYAML(y *yaml.Node) error { func (c *Config) UnmarshalYAML(y *yaml.Node) error {
@ -41,7 +41,7 @@ func (c *Config) UnmarshalYAML(y *yaml.Node) error {
for i := 0; i < len(y.Content); i += 2 { for i := 0; i < len(y.Content); i += 2 {
k, v := y.Content[i], y.Content[i+1] k, v := y.Content[i], y.Content[i+1]
switch v.LongTag() { switch v.LongTag() {
case IncludeTag: case IncludeTag:
fallthrough fallthrough
case IncludeDirNamedTag: case IncludeDirNamedTag:

View file

@ -18,7 +18,7 @@ func ReadConfig() (*Config, error) {
return nil, err return nil, err
} }
cfgPath := path.Join(home, "/." + common.AppName, "/config.yaml") cfgPath := path.Join(home, "/."+common.AppName, "/config.yaml")
r, err := os.Open(cfgPath) r, err := os.Open(cfgPath)
if err != nil { if err != nil {

View file

@ -13,14 +13,13 @@ type AuthProvider interface {
} }
type AuthProviderBase struct { type AuthProviderBase struct {
Name string `json:"name"` Name string `json:"name"`
ID *string `json:"id"` ID *string `json:"id"`
Type string `json:"type"` Type string `json:"type"`
} }
func (bp *AuthProviderBase) ProviderName() string { return bp.Name } func (bp *AuthProviderBase) ProviderName() string { return bp.Name }
func (bp *AuthProviderBase) ProviderID() *string { return bp.ID } func (bp *AuthProviderBase) ProviderID() *string { return bp.ID }
func (bp *AuthProviderBase) ProviderType() string { return bp.Type } func (bp *AuthProviderBase) ProviderType() string { return bp.Type }
type LocalProvider struct { type LocalProvider struct {
@ -69,3 +68,20 @@ func (s *Server) authorizeHandler(w http.ResponseWriter, r *http.Request) {
panic(err) panic(err)
} }
} }
type flowRequest struct {
ClientID string `json:"client_id"`
Handler []*string `json:"handler"`
RedirectURI string `json:"redirect_uri"`
}
func (s *Server) loginFlowHandler(w http.ResponseWriter, r *http.Request) {
var flowReq flowRequest
err := json.NewDecoder(r.Body).Decode(&flowReq)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
}

View file

@ -15,8 +15,8 @@ type Server struct {
*bus.Bus *bus.Bus
*http.Server *http.Server
rootFS fs.FS rootFS fs.FS
wg sync.WaitGroup wg sync.WaitGroup
cfg *config.Config cfg *config.Config
} }
type StatusWriter struct { type StatusWriter struct {
@ -48,7 +48,7 @@ func New(cfg *config.Config) (s *Server, err error) {
s = &Server{ s = &Server{
Bus: bus.New(), Bus: bus.New(),
Server: &http.Server{ Server: &http.Server{
Addr: cfg.Server.Bind, Addr: cfg.Server.Bind,
Handler: mux, Handler: mux,
}, },
cfg: cfg, cfg: cfg,

View file

@ -8,7 +8,7 @@ import (
) )
var upgrader = websocket.Upgrader{ var upgrader = websocket.Upgrader{
ReadBufferSize: 1024, ReadBufferSize: 1024,
WriteBufferSize: 1024, WriteBufferSize: 1024,
} }