diff --git a/.golangci.yml b/.golangci.yml index 5e88798..7b61b1a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,10 +2,14 @@ run: tests: true skip-dirs: + - builtin + - examples + - Godeps - locales - testdata + - third_party + - vendor - web - skip-dirs-use-default: true skip-files: - ".*_gen\\.go$" output: @@ -33,6 +37,7 @@ linters-settings: ignore-map-index-ok: true ignore-chan-recv-ok: true ignore-names: + - cid # ClientID - ctx # context - db # dataBase - err # error @@ -43,16 +48,17 @@ linters-settings: - ln # listener - me - ok + - r # Request - tc # testCase - ts # timeStamp - tx # transaction + - w # ResponseWriter ignore-decls: - - "cid *domain.ClientID" - - "ctx *fasthttp.RequestCtx" - "ctx context.Context" + - "err error" - "i int" - - "me *domain.Me" - - "r *router.Router" + - "r *http.Request" + - "w http.ResponseWriter" linters: enable-all: true disable: diff --git a/main.go b/main.go index 036bdbe..7c7f8b4 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ package main import ( "context" "embed" - _ "embed" "errors" "flag" "io/fs" @@ -96,9 +95,11 @@ var ( // NOTE(toby3d): read configuration from environment, see: https://12factor.net/config config = new(domain.Config) indieAuthClient = &domain.Client{ - URL: make([]*url.URL, 1), + ID: domain.ClientID{}, Logo: make([]*url.URL, 1), RedirectURI: make([]*url.URL, 1), + URL: make([]*url.URL, 1), + Name: make([]string, 0), } ) @@ -115,7 +116,11 @@ func init() { flag.Parse() if err := env.Parse(&config, env.Options{ - Prefix: "INDIEAUTH_", + Environment: nil, + OnSet: nil, + Prefix: "INDIEAUTH_", + RequiredIfNoDef: false, + TagName: "", }); err != nil { logger.Fatalln(err) } @@ -185,12 +190,20 @@ func main() { app := NewApp(opts) - //nolint:exhaustivestruct server := &http.Server{ - Addr: config.Server.GetAddress(), - Handler: app.Handler(), - ReadTimeout: DefaultReadTimeout, - WriteTimeout: DefaultWriteTimeout, + Addr: config.Server.GetAddress(), + BaseContext: nil, + ConnContext: nil, + ConnState: nil, + ErrorLog: logger, + Handler: app.Handler(), + IdleTimeout: 0, + MaxHeaderBytes: 0, + ReadHeaderTimeout: 0, + ReadTimeout: DefaultReadTimeout, + TLSConfig: nil, + TLSNextProto: nil, + WriteTimeout: DefaultWriteTimeout, } done := make(chan os.Signal, 1) @@ -261,7 +274,10 @@ func NewApp(opts NewAppOptions) *App { } // TODO(toby3d): move module middlewares to here. +// +//nolint:funlen func (app *App) Handler() http.Handler { + //nolint:exhaustivestruct metadata := metadatahttpdelivery.NewHandler(&domain.Metadata{ Issuer: indieAuthClient.ID.URL(), AuthorizationEndpoint: indieAuthClient.ID.URL().JoinPath("authorize"), @@ -272,7 +288,11 @@ func (app *App) Handler() http.Handler { IntrospectionEndpoint: indieAuthClient.ID.URL().JoinPath("introspect"), RevocationEndpoint: indieAuthClient.ID.URL().JoinPath("revocation"), UserinfoEndpoint: indieAuthClient.ID.URL().JoinPath("userinfo"), - ServiceDocumentation: &url.URL{Scheme: "https", Host: "indieauth.net", Path: "/source/"}, + ServiceDocumentation: &url.URL{ + Scheme: "https", + Host: "indieauth.net", + Path: "/source/", + }, IntrospectionEndpointAuthMethodsSupported: []string{"Bearer"}, RevocationEndpointAuthMethodsSupported: []string{"none"}, ScopesSupported: domain.Scopes{