diff --git a/pkg/bus/bus.go b/pkg/bus/bus.go index c5863e4..2af8776 100644 --- a/pkg/bus/bus.go +++ b/pkg/bus/bus.go @@ -1,14 +1,12 @@ package bus -import ( -) +import () type Bus struct { } func New() *Bus { - bus := &Bus{ - } + bus := &Bus{} return bus } diff --git a/pkg/cmd/serve/cmd.go b/pkg/cmd/serve/cmd.go index 73d0b0c..c47f40e 100644 --- a/pkg/cmd/serve/cmd.go +++ b/pkg/cmd/serve/cmd.go @@ -15,9 +15,9 @@ type ServeOptions struct { func Command(cfg *config.Config) *cobra.Command { opts := makeOptions(cfg) serveCmd := &cobra.Command{ - Use: "serve", + Use: "serve", Short: "starts the " + common.AppName + " server", - RunE: common.RunE(opts), + RunE: common.RunE(opts), } return serveCmd diff --git a/pkg/config/config.go b/pkg/config/config.go index e2235f1..7a6f946 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -16,11 +16,11 @@ type Config struct { } const ( - IncludeTag = "!include" - IncludeDirNamedTag = "!include_dir_named" - IncludeDirListTag = "!include_dir_list" + IncludeTag = "!include" + IncludeDirNamedTag = "!include_dir_named" + IncludeDirListTag = "!include_dir_list" IncludeDirMergeNamedTag = "!include_dir_merge_named" - SecretTag = "!secret" + SecretTag = "!secret" ) 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 { k, v := y.Content[i], y.Content[i+1] - switch v.LongTag() { + switch v.LongTag() { case IncludeTag: fallthrough case IncludeDirNamedTag: diff --git a/pkg/config/read.go b/pkg/config/read.go index 7a6130a..f094ceb 100644 --- a/pkg/config/read.go +++ b/pkg/config/read.go @@ -18,7 +18,7 @@ func ReadConfig() (*Config, error) { return nil, err } - cfgPath := path.Join(home, "/." + common.AppName, "/config.yaml") + cfgPath := path.Join(home, "/."+common.AppName, "/config.yaml") r, err := os.Open(cfgPath) if err != nil { diff --git a/pkg/server/authorize.go b/pkg/server/authorize.go index e70e57f..37656a6 100644 --- a/pkg/server/authorize.go +++ b/pkg/server/authorize.go @@ -13,14 +13,13 @@ type AuthProvider interface { } type AuthProviderBase struct { - Name string `json:"name"` - ID *string `json:"id"` - Type string `json:"type"` + Name string `json:"name"` + ID *string `json:"id"` + Type string `json:"type"` } - 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 } type LocalProvider struct { @@ -69,3 +68,20 @@ func (s *Server) authorizeHandler(w http.ResponseWriter, r *http.Request) { 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 + } + +} diff --git a/pkg/server/server.go b/pkg/server/server.go index 4363a75..c38bf9d 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -15,8 +15,8 @@ type Server struct { *bus.Bus *http.Server rootFS fs.FS - wg sync.WaitGroup - cfg *config.Config + wg sync.WaitGroup + cfg *config.Config } type StatusWriter struct { @@ -48,7 +48,7 @@ func New(cfg *config.Config) (s *Server, err error) { s = &Server{ Bus: bus.New(), Server: &http.Server{ - Addr: cfg.Server.Bind, + Addr: cfg.Server.Bind, Handler: mux, }, cfg: cfg, diff --git a/pkg/server/websocket.go b/pkg/server/websocket.go index 21cc0d6..1796b42 100644 --- a/pkg/server/websocket.go +++ b/pkg/server/websocket.go @@ -8,7 +8,7 @@ import ( ) var upgrader = websocket.Upgrader{ - ReadBufferSize: 1024, + ReadBufferSize: 1024, WriteBufferSize: 1024, }