🎨 Format GolangCI-Lint comments
This commit is contained in:
parent
c6699bb312
commit
e0d9212678
|
@ -347,7 +347,7 @@ func NewAuthAuthorizationRequest() *AuthAuthorizationRequest {
|
|||
}
|
||||
}
|
||||
|
||||
//nolint: cyclop
|
||||
//nolint:cyclop
|
||||
func (r *AuthAuthorizationRequest) bind(ctx *http.RequestCtx) error {
|
||||
indieAuthError := new(domain.Error)
|
||||
if err := form.Unmarshal(ctx.QueryArgs().QueryString(), r); err != nil {
|
||||
|
@ -384,7 +384,7 @@ func NewAuthVerifyRequest() *AuthVerifyRequest {
|
|||
}
|
||||
}
|
||||
|
||||
//nolint: funlen,cyclop
|
||||
//nolint:funlen,cyclop
|
||||
func (r *AuthVerifyRequest) bind(ctx *http.RequestCtx) error {
|
||||
indieAuthError := new(domain.Error)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ func TestAuthorize(t *testing.T) {
|
|||
deps.store.Store(path.Join(userrepo.DefaultPathPrefix, me.String()), user)
|
||||
|
||||
r := router.New()
|
||||
//nolint: exhaustivestruct
|
||||
//nolint:exhaustivestruct
|
||||
delivery.NewRequestHandler(delivery.NewRequestHandlerOptions{
|
||||
Auth: deps.authService,
|
||||
Clients: deps.clientService,
|
||||
|
|
|
@ -87,7 +87,7 @@ func (h *RequestHandler) handleRender(ctx *http.RequestCtx) {
|
|||
})
|
||||
}
|
||||
|
||||
//nolint: funlen
|
||||
//nolint:unlen
|
||||
func (h *RequestHandler) handleCallback(ctx *http.RequestCtx) {
|
||||
ctx.SetContentType(common.MIMETextHTMLCharsetUTF8)
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ func (repo *httpClientRepository) Get(ctx context.Context, cid *domain.ClientID)
|
|||
return client, nil
|
||||
}
|
||||
|
||||
//nolint: gocognit, cyclop
|
||||
//nolint:gocognit,cyclop
|
||||
func extract(dst *domain.Client, src *http.Response) {
|
||||
for _, endpoint := range httputil.ExtractEndpoints(src, relRedirectURI) {
|
||||
if !containsURL(dst.RedirectURI, endpoint) {
|
||||
|
|
|
@ -15,7 +15,7 @@ type Action struct {
|
|||
uid string
|
||||
}
|
||||
|
||||
//nolint: gochecknoglobals // structs cannot be constants
|
||||
//nolint:gochecknoglobals // structs cannot be constants
|
||||
var (
|
||||
ActionUnd = Action{uid: ""} // "und"
|
||||
|
||||
|
@ -28,7 +28,7 @@ var (
|
|||
|
||||
var ErrActionSyntax error = NewError(ErrorCodeInvalidRequest, "unknown action method", "")
|
||||
|
||||
//nolint: gochecknoglobals
|
||||
//nolint:gochecknoglobals
|
||||
var uidsActions = map[string]Action{
|
||||
ActionRevoke.uid: ActionRevoke,
|
||||
ActionTicket.uid: ActionTicket,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//nolint: dupl
|
||||
//nolint:dupl
|
||||
package domain_test
|
||||
|
||||
import (
|
||||
|
|
|
@ -16,14 +16,15 @@ type ClientID struct {
|
|||
clientID *http.URI
|
||||
}
|
||||
|
||||
//nolint: gochecknoglobals // slices cannot be constants
|
||||
//nolint:gochecknoglobals // slices cannot be constants
|
||||
var (
|
||||
localhostIPv4 = netaddr.MustParseIP("127.0.0.1")
|
||||
localhostIPv6 = netaddr.MustParseIP("::1")
|
||||
)
|
||||
|
||||
// ParseClientID parse string as client ID URL identifier.
|
||||
//nolint: funlen, cyclop
|
||||
//
|
||||
//nolint:funlen,cyclop
|
||||
func ParseClientID(src string) (*ClientID, error) {
|
||||
cid := http.AcquireURI()
|
||||
if err := cid.Parse(nil, []byte(src)); err != nil {
|
||||
|
@ -82,7 +83,7 @@ func ParseClientID(src string) (*ClientID, error) {
|
|||
if err != nil {
|
||||
ipPort, err := netaddr.ParseIPPort(domain)
|
||||
if err != nil {
|
||||
//nolint: nilerr // ClientID does not contain an IP address, so it is valid
|
||||
//nolint:nilerr // ClientID does not contain an IP address, so it is valid
|
||||
return &ClientID{clientID: cid}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package domain
|
||||
|
||||
//nolint: gosec // support old clients
|
||||
//nolint:gosec // support old clients
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/sha1"
|
||||
|
@ -23,7 +23,7 @@ type CodeChallengeMethod struct {
|
|||
uid string
|
||||
}
|
||||
|
||||
//nolint: gochecknoglobals // structs cannot be constants
|
||||
//nolint:gochecknoglobals // structs cannot be constants
|
||||
var (
|
||||
CodeChallengeMethodUnd = CodeChallengeMethod{uid: ""} // "und"
|
||||
CodeChallengeMethodPLAIN = CodeChallengeMethod{uid: "plain"} // "PLAIN"
|
||||
|
@ -39,7 +39,7 @@ var ErrCodeChallengeMethodUnknown error = NewError(
|
|||
"https://indieauth.net/source/#authorization-request",
|
||||
)
|
||||
|
||||
//nolint: gochecknoglobals // maps cannot be constants
|
||||
//nolint:gochecknoglobals // maps cannot be constants
|
||||
var uidsMethods = map[string]CodeChallengeMethod{
|
||||
CodeChallengeMethodMD5.uid: CodeChallengeMethodMD5,
|
||||
CodeChallengeMethodPLAIN.uid: CodeChallengeMethodPLAIN,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package domain_test
|
||||
|
||||
//nolint: gosec // support old clients
|
||||
//nolint:gosec // support old clients
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/sha1"
|
||||
|
@ -110,7 +110,7 @@ func TestCodeChallengeMethod_String(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
//nolint: gosec // support old clients
|
||||
//nolint:gosec // support old clients
|
||||
func TestCodeChallengeMethod_Validate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
|
@ -78,7 +78,8 @@ type (
|
|||
)
|
||||
|
||||
// TestConfig returns a valid config for tests.
|
||||
//nolint: gomnd // testing domain can contains non-standart values
|
||||
//
|
||||
//nolint:gomnd // testing domain can contains non-standart values
|
||||
func TestConfig(tb testing.TB) *Config {
|
||||
tb.Helper()
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ func TestParseEmail(t *testing.T) {
|
|||
func TestEmail_String(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
email := domain.TestEmail(t) //nolint: ifshort
|
||||
email := domain.TestEmail(t) //nolint:ifshort
|
||||
if result := email.String(); result != fmt.Sprint(email) {
|
||||
t.Errorf("String() = %v, want %v", result, email)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
type (
|
||||
// Error describes the format of a typical IndieAuth error.
|
||||
//nolint: tagliatelle // RFC 6749 section 5.2
|
||||
//nolint:tagliatelle // RFC 6749 section 5.2
|
||||
Error struct {
|
||||
// A single error code.
|
||||
Code ErrorCode `json:"error"`
|
||||
|
@ -150,7 +150,7 @@ var (
|
|||
|
||||
var ErrErrorCodeUnknown error = NewError(ErrorCodeInvalidRequest, "unknown error code", "")
|
||||
|
||||
//nolint: gochecknoglobals // maps cannot be constants
|
||||
//nolint:gochecknoglobals // maps cannot be constants
|
||||
var uidsErrorCodes = map[string]ErrorCode{
|
||||
ErrorCodeAccessDenied.uid: ErrorCodeAccessDenied,
|
||||
ErrorCodeInsufficientScope.uid: ErrorCodeInsufficientScope,
|
||||
|
|
|
@ -16,7 +16,7 @@ type GrantType struct {
|
|||
uid string
|
||||
}
|
||||
|
||||
//nolint: gochecknoglobals // structs cannot be constants
|
||||
//nolint:gochecknoglobals // structs cannot be constants
|
||||
var (
|
||||
GrantTypeUnd = GrantType{uid: ""} // "und"
|
||||
GrantTypeAuthorizationCode = GrantType{uid: "authorization_code"} // "authorization_code"
|
||||
|
@ -32,7 +32,7 @@ var ErrGrantTypeUnknown error = NewError(
|
|||
"",
|
||||
)
|
||||
|
||||
//nolint: gochecknoglobals // maps cannot be constants
|
||||
//nolint:gochecknoglobals // maps cannot be constants
|
||||
var uidsGrantTypes = map[string]GrantType{
|
||||
GrantTypeAuthorizationCode.uid: GrantTypeAuthorizationCode,
|
||||
GrantTypeRefreshToken.uid: GrantTypeRefreshToken,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//nolint: dupl
|
||||
//nolint:dupl
|
||||
package domain_test
|
||||
|
||||
import (
|
||||
|
|
|
@ -17,7 +17,8 @@ type Me struct {
|
|||
}
|
||||
|
||||
// ParseMe parse string as me URL identifier.
|
||||
//nolint: funlen, cyclop
|
||||
//
|
||||
//nolint:funlen,cyclop
|
||||
func ParseMe(raw string) (*Me, error) {
|
||||
id := http.AcquireURI()
|
||||
if err := id.Parse(nil, []byte(raw)); err != nil {
|
||||
|
|
|
@ -21,7 +21,7 @@ type Provider struct {
|
|||
URL string
|
||||
}
|
||||
|
||||
//nolint: gochecknoglobals // structs cannot be contants
|
||||
//nolint:gochecknoglobals // structs cannot be contants
|
||||
var (
|
||||
ProviderDirect = Provider{
|
||||
AuthURL: "/authorize",
|
||||
|
|
|
@ -14,7 +14,7 @@ type ResponseType struct {
|
|||
uid string
|
||||
}
|
||||
|
||||
//nolint: gochecknoglobals // structs cannot be constants
|
||||
//nolint:gochecknoglobals // structs cannot be constants
|
||||
var (
|
||||
ResponseTypeUnd = ResponseType{uid: ""} // "und"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//nolint: dupl
|
||||
//nolint:dupl
|
||||
package domain_test
|
||||
|
||||
import (
|
||||
|
|
|
@ -23,7 +23,7 @@ type (
|
|||
|
||||
var ErrScopeUnknown error = NewError(ErrorCodeInvalidRequest, "unknown scope", "https://indieweb.org/scope")
|
||||
|
||||
//nolint: gochecknoglobals // structs cannot be constants
|
||||
//nolint:gochecknoglobals // structs cannot be constants
|
||||
var (
|
||||
ScopeUnd = Scope{uid: ""} // "und"
|
||||
|
||||
|
@ -59,7 +59,7 @@ var (
|
|||
ScopeEmail = Scope{uid: "email"} // "email"
|
||||
)
|
||||
|
||||
//nolint: gochecknoglobals // maps cannot be constants
|
||||
//nolint:gochecknoglobals // maps cannot be constants
|
||||
var uidsScopes = map[string]Scope{
|
||||
ScopeBlock.uid: ScopeBlock,
|
||||
ScopeChannels.uid: ScopeChannels,
|
||||
|
|
|
@ -95,7 +95,6 @@ func TestScopes_MarshalJSON(t *testing.T) {
|
|||
func TestScope_String(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
//nolint: paralleltest // false positive, in is used
|
||||
for _, tc := range []struct {
|
||||
in domain.Scope
|
||||
out string
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"source.toby3d.me/toby3d/auth/internal/random"
|
||||
)
|
||||
|
||||
//nolint: tagliatelle
|
||||
//nolint:tagliatelle
|
||||
type Session struct {
|
||||
ClientID *ClientID `json:"client_id"`
|
||||
RedirectURI *URL `json:"redirect_uri"`
|
||||
|
@ -19,7 +19,8 @@ type Session struct {
|
|||
}
|
||||
|
||||
// TestSession returns valid random generated session for tests.
|
||||
//nolint: gomnd // testing domain can contains non-standart values
|
||||
//
|
||||
//nolint:gomnd // testing domain can contains non-standart values
|
||||
func TestSession(tb testing.TB) *Session {
|
||||
tb.Helper()
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ type (
|
|||
)
|
||||
|
||||
// DefaultNewTokenOptions describes the default settings for NewToken.
|
||||
//nolint: gochecknoglobals, gomnd
|
||||
//
|
||||
//nolint:gochecknoglobals,gomnd
|
||||
var DefaultNewTokenOptions = NewTokenOptions{
|
||||
Expiration: 0,
|
||||
Scope: nil,
|
||||
|
@ -49,7 +50,8 @@ var DefaultNewTokenOptions = NewTokenOptions{
|
|||
}
|
||||
|
||||
// NewToken create a new token by provided options.
|
||||
//nolint: cyclop
|
||||
//
|
||||
//nolint:cyclop
|
||||
func NewToken(opts NewTokenOptions) (*Token, error) {
|
||||
if opts.NonceLength == 0 {
|
||||
opts.NonceLength = DefaultNewTokenOptions.NonceLength
|
||||
|
@ -109,7 +111,8 @@ func NewToken(opts NewTokenOptions) (*Token, error) {
|
|||
}
|
||||
|
||||
// TestToken returns valid random generated token for tests.
|
||||
//nolint: gomnd // testing domain can contains non-standart values
|
||||
//
|
||||
//nolint:gomnd // testing domain can contains non-standart values
|
||||
func TestToken(tb testing.TB) *Token {
|
||||
tb.Helper()
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ func ExtractMetadata(resp *http.Response, client *http.Client) (*domain.Metadata
|
|||
}
|
||||
|
||||
func ExtractProperty(resp *http.Response, itemType, key string) []interface{} {
|
||||
//nolint: exhaustivestruct // only Host part in url.URL is needed
|
||||
//nolint:exhaustivestruct // only Host part in url.URL is needed
|
||||
data := microformats.Parse(bytes.NewReader(resp.Body()), &url.URL{
|
||||
Host: string(resp.Header.Peek(http.HeaderHost)),
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type (
|
||||
//nolint: tagliatelle // https://indieauth.net/source/#indieauth-server-metadata
|
||||
//nolint:tagliatelle // https://indieauth.net/source/#indieauth-server-metadata
|
||||
MetadataResponse struct {
|
||||
// The server's issuer identifier.
|
||||
Issuer string `json:"issuer"`
|
||||
|
@ -27,13 +27,13 @@ type (
|
|||
|
||||
// JSON array containing a list of client authentication methods
|
||||
// supported by this introspection endpoint.
|
||||
IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported,omitempty"` //nolint: lll
|
||||
IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported,omitempty"` //nolint:lll
|
||||
|
||||
// The Revocation Endpoint.
|
||||
RevocationEndpoint string `json:"revocation_endpoint,omitempty"`
|
||||
|
||||
// JSON array containing the value "none".
|
||||
RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"` //nolint: lll
|
||||
RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"` //nolint:lll
|
||||
|
||||
// JSON array containing scope values supported by the
|
||||
// IndieAuth server.
|
||||
|
@ -54,7 +54,7 @@ type (
|
|||
|
||||
// Boolean parameter indicating whether the authorization server
|
||||
// provides the iss parameter.
|
||||
AuthorizationResponseIssParameterSupported bool `json:"authorization_response_iss_parameter_supported,omitempty"` //nolint: lll
|
||||
AuthorizationResponseIssParameterSupported bool `json:"authorization_response_iss_parameter_supported,omitempty"` //nolint:lll
|
||||
|
||||
// The User Info Endpoint.
|
||||
UserinfoEndpoint string `json:"userinfo_endpoint,omitempty"`
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
type (
|
||||
//nolint: tagliatelle,lll
|
||||
//nolint:tagliatelle,lll
|
||||
Metadata struct {
|
||||
Issuer *domain.ClientID `json:"issuer"`
|
||||
AuthorizationEndpoint *domain.URL `json:"authorization_endpoint"`
|
||||
|
@ -72,7 +72,7 @@ func (repo *httpMetadataRepository) Get(ctx context.Context, me *domain.Me) (*do
|
|||
return nil, fmt.Errorf("cannot unmarshal metadata configuration: %w", err)
|
||||
}
|
||||
|
||||
//nolint: exhaustivestruct // TODO(toby3d)
|
||||
//nolint:exhaustivestruct // TODO(toby3d)
|
||||
return &domain.Metadata{
|
||||
AuthorizationEndpoint: data.AuthorizationEndpoint,
|
||||
AuthorizationResponseIssParameterSupported: data.AuthorizationResponseIssParameterSupported,
|
||||
|
|
|
@ -32,7 +32,7 @@ func NewHTPPClientRepository(client *http.Client) profile.Repository {
|
|||
}
|
||||
}
|
||||
|
||||
//nolint: cyclop
|
||||
//nolint:cyclop
|
||||
func (repo *httpProfileRepository) Get(ctx context.Context, me *domain.Me) (*domain.Profile, error) {
|
||||
req := http.AcquireRequest()
|
||||
defer http.ReleaseRequest(req)
|
||||
|
|
|
@ -67,7 +67,7 @@ func (repo *sqlite3SessionRepository) Create(ctx context.Context, session *domai
|
|||
}
|
||||
|
||||
func (repo *sqlite3SessionRepository) Get(ctx context.Context, code string) (*domain.Session, error) {
|
||||
s := new(Session) //nolint: varnamelen // cannot redaclare import
|
||||
s := new(Session) //nolint:varnamelen // cannot redaclare import
|
||||
if err := repo.db.GetContext(ctx, s, QueryGet, code); err != nil {
|
||||
return nil, fmt.Errorf("cannot find session in db: %w", err)
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func (repo *sqlite3SessionRepository) Get(ctx context.Context, code string) (*do
|
|||
}
|
||||
|
||||
func (repo *sqlite3SessionRepository) GetAndDelete(ctx context.Context, code string) (*domain.Session, error) {
|
||||
s := new(Session) //nolint: varnamelen // cannot redaclare import
|
||||
s := new(Session) //nolint:varnamelen // cannot redaclare import
|
||||
|
||||
tx, err := repo.db.Beginx()
|
||||
if err != nil {
|
||||
|
@ -93,7 +93,7 @@ func (repo *sqlite3SessionRepository) GetAndDelete(ctx context.Context, code str
|
|||
}
|
||||
|
||||
if err = tx.GetContext(ctx, s, QueryGet, code); err != nil {
|
||||
//nolint: errcheck // deffered method
|
||||
//nolint:errcheck // deffered method
|
||||
defer tx.Rollback()
|
||||
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
|
|
|
@ -24,7 +24,7 @@ var (
|
|||
func New(tb testing.TB, handler http.RequestHandler) (*http.Client, *http.Server, func()) {
|
||||
tb.Helper()
|
||||
|
||||
//nolint: exhaustivestruct
|
||||
//nolint:exhaustivestruct
|
||||
server := &http.Server{
|
||||
CloseOnShutdown: true,
|
||||
DisableKeepalive: true,
|
||||
|
@ -34,16 +34,16 @@ func New(tb testing.TB, handler http.RequestHandler) (*http.Client, *http.Server
|
|||
|
||||
ln := httputil.NewInmemoryListener()
|
||||
|
||||
//nolint: errcheck
|
||||
//nolint:errcheck
|
||||
go server.ServeTLSEmbed(ln, certData, keyData)
|
||||
|
||||
//nolint: exhaustivestruct
|
||||
//nolint:exhaustivestruct
|
||||
client := &http.Client{
|
||||
TLSConfig: &tls.Config{
|
||||
InsecureSkipVerify: true, //nolint: gosec
|
||||
InsecureSkipVerify: true, //nolint:gosec
|
||||
},
|
||||
Dial: func(addr string) (net.Conn, error) {
|
||||
return ln.Dial() //nolint: wrapcheck
|
||||
return ln.Dial() //nolint:wrapcheck
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ func NewRequestHandler(tickets ticket.UseCase, matcher language.Matcher, config
|
|||
}
|
||||
|
||||
func (h *RequestHandler) Register(r *router.Router) {
|
||||
//nolint: exhaustivestruct
|
||||
//nolint:exhaustivestruct
|
||||
chain := middleware.Chain{
|
||||
middleware.CSRFWithConfig(middleware.CSRFConfig{
|
||||
Skipper: func(ctx *http.RequestCtx) bool {
|
||||
|
|
|
@ -73,7 +73,7 @@ func (repo *sqlite3TicketRepository) GetAndDelete(ctx context.Context, rawTicket
|
|||
|
||||
tkt := new(Ticket)
|
||||
if err = tx.GetContext(ctx, tkt, QueryGet, rawTicket); err != nil {
|
||||
//nolint: errcheck // deffered method
|
||||
//nolint:errcheck // deffered method
|
||||
defer tx.Rollback()
|
||||
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
type (
|
||||
//nolint: tagliatelle // https://indieauth.net/source/#access-token-response
|
||||
//nolint:tagliatelle // https://indieauth.net/source/#access-token-response
|
||||
AccessToken struct {
|
||||
Me *domain.Me `json:"me"`
|
||||
Profile *Profile `json:"profile,omitempty"`
|
||||
|
|
|
@ -55,7 +55,7 @@ type (
|
|||
Token string `form:"token"`
|
||||
}
|
||||
|
||||
//nolint: tagliatelle // https://indieauth.net/source/#access-token-response
|
||||
//nolint:tagliatelle // https://indieauth.net/source/#access-token-response
|
||||
TokenExchangeResponse struct {
|
||||
// The OAuth 2.0 Bearer Token RFC6750.
|
||||
AccessToken string `json:"access_token"`
|
||||
|
@ -90,7 +90,7 @@ type (
|
|||
Email string `json:"email,omitempty"`
|
||||
}
|
||||
|
||||
//nolint: tagliatelle // https://indieauth.net/source/#access-token-verification-response
|
||||
//nolint:tagliatelle // https://indieauth.net/source/#access-token-verification-response
|
||||
TokenIntrospectResponse struct {
|
||||
// Boolean indicator of whether or not the presented token is
|
||||
// currently active.
|
||||
|
@ -138,7 +138,7 @@ func NewRequestHandler(tokens token.UseCase, tickets ticket.UseCase, config *dom
|
|||
|
||||
func (h *RequestHandler) Register(r *router.Router) {
|
||||
chain := middleware.Chain{
|
||||
//nolint: exhaustivestruct
|
||||
//nolint:exhaustivestruct
|
||||
middleware.JWTWithConfig(middleware.JWTConfig{
|
||||
AuthScheme: "Bearer",
|
||||
ContextKey: "token",
|
||||
|
@ -227,7 +227,7 @@ func (h *RequestHandler) handleAction(ctx *http.RequestCtx) {
|
|||
}
|
||||
}
|
||||
|
||||
//nolint: funlen
|
||||
//nolint:funlen
|
||||
func (h *RequestHandler) handleExchange(ctx *http.RequestCtx) {
|
||||
ctx.SetContentType(common.MIMEApplicationJSONCharsetUTF8)
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ func TestRevocation(t *testing.T) {
|
|||
t.Errorf("POST %s = %d, want %d", requestURL, result, http.StatusOK)
|
||||
}
|
||||
|
||||
expBody := []byte("{}") //nolint: ifshort
|
||||
expBody := []byte("{}") //nolint:ifshort
|
||||
if result := bytes.TrimSpace(resp.Body()); !bytes.Equal(result, expBody) {
|
||||
t.Errorf("POST %s = %s, want %s", requestURL, result, expBody)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
repository "source.toby3d.me/toby3d/auth/internal/token/repository/sqlite3"
|
||||
)
|
||||
|
||||
//nolint: gochecknoglobals // slices cannot be contants
|
||||
//nolint:gochecknoglobals // slices cannot be contants
|
||||
var tableColumns = []string{"created_at", "access_token", "client_id", "me", "scope"}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
|
|
|
@ -41,7 +41,7 @@ func NewTokenUseCase(config Config) token.UseCase {
|
|||
}
|
||||
}
|
||||
|
||||
//nolint: cyclop
|
||||
//nolint:cyclop
|
||||
func (uc *tokenUseCase) Exchange(ctx context.Context, opts token.ExchangeOptions) (*domain.Token, *domain.Profile,
|
||||
error,
|
||||
) {
|
||||
|
@ -129,7 +129,7 @@ func (uc *tokenUseCase) Verify(ctx context.Context, accessToken string) (*domain
|
|||
|
||||
profile, err := uc.profiles.Get(ctx, result.Me)
|
||||
if err != nil {
|
||||
return result, nil, nil //nolint: nilerr // it's okay to return result without profile
|
||||
return result, nil, nil //nolint:nilerr // it's okay to return result without profile
|
||||
}
|
||||
|
||||
if !result.Scope.Has(domain.ScopeEmail) && len(profile.Email) > 0 {
|
||||
|
|
|
@ -37,7 +37,7 @@ func NewRequestHandler(tokens token.UseCase, config *domain.Config) *RequestHand
|
|||
|
||||
func (h *RequestHandler) Register(r *router.Router) {
|
||||
chain := middleware.Chain{
|
||||
//nolint: exhaustivestruct
|
||||
//nolint:exhaustivestruct
|
||||
middleware.JWTWithConfig(middleware.JWTConfig{
|
||||
AuthScheme: "Bearer",
|
||||
ContextKey: "token",
|
||||
|
@ -63,7 +63,7 @@ func (h *RequestHandler) handleUserInformation(ctx *http.RequestCtx) {
|
|||
if err != nil || tkn == nil {
|
||||
// WARN(toby3d): If the token is not valid, the endpoint still
|
||||
// MUST return a 200 Response.
|
||||
_ = encoder.Encode(err) //nolint: errchkjson
|
||||
_ = encoder.Encode(err) //nolint:errchkjson
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ func (h *RequestHandler) handleUserInformation(ctx *http.RequestCtx) {
|
|||
if !tkn.Scope.Has(domain.ScopeProfile) {
|
||||
ctx.SetStatusCode(http.StatusForbidden)
|
||||
|
||||
//nolint: errchkjson
|
||||
//nolint:errchkjson
|
||||
_ = encoder.Encode(domain.NewError(
|
||||
domain.ErrorCodeInsufficientScope,
|
||||
"token with 'profile' scope is required to view profile data",
|
||||
|
@ -83,7 +83,7 @@ func (h *RequestHandler) handleUserInformation(ctx *http.RequestCtx) {
|
|||
|
||||
resp := new(UserInformationResponse)
|
||||
if userInfo == nil {
|
||||
_ = encoder.Encode(resp) //nolint: errchkjson
|
||||
_ = encoder.Encode(resp) //nolint:errchkjson
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -104,5 +104,5 @@ func (h *RequestHandler) handleUserInformation(ctx *http.RequestCtx) {
|
|||
resp.Email = userInfo.GetEmail().String()
|
||||
}
|
||||
|
||||
_ = encoder.Encode(resp) //nolint: errchkjson
|
||||
_ = encoder.Encode(resp) //nolint:errchkjson
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ func (repo *httpUserRepository) Get(ctx context.Context, me *domain.Me) (*domain
|
|||
return user, nil
|
||||
}
|
||||
|
||||
//nolint: cyclop
|
||||
//nolint:cyclop
|
||||
func extractUser(dst *domain.User, src *http.Response) {
|
||||
if dst.IndieAuthMetadata != nil {
|
||||
if endpoints := httputil.ExtractEndpoints(src, relIndieAuthMetadata); len(endpoints) > 0 {
|
||||
|
|
12
main.go
12
main.go
|
@ -87,7 +87,7 @@ const (
|
|||
DefaultWriteTimeout time.Duration = 10 * time.Second
|
||||
)
|
||||
|
||||
//nolint: gochecknoglobals
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
// NOTE(toby3d): write logs in stdout, see: https://12factor.net/logs
|
||||
logger = log.New(os.Stdout, "IndieAuth\t", log.Lmsgprefix|log.LstdFlags|log.LUTC)
|
||||
|
@ -100,7 +100,7 @@ var (
|
|||
enablePprof bool
|
||||
)
|
||||
|
||||
//nolint: gochecknoinits
|
||||
//nolint:gochecknoinits
|
||||
func init() {
|
||||
flag.StringVar(&configPath, "config", filepath.Join(".", "config.yml"), "load specific config")
|
||||
flag.BoolVar(&enablePprof, "pprof", false, "enable pprof mode")
|
||||
|
@ -157,7 +157,7 @@ func init() {
|
|||
indieAuthClient.RedirectURI = []*domain.URL{redirectURI}
|
||||
}
|
||||
|
||||
//nolint: funlen, cyclop // "god object" and the entry point of all modules
|
||||
//nolint:funlen,cyclop // "god object" and the entry point of all modules
|
||||
func main() {
|
||||
var opts NewAppOptions
|
||||
|
||||
|
@ -186,7 +186,7 @@ func main() {
|
|||
|
||||
go opts.Sessions.GC()
|
||||
|
||||
//nolint: exhaustivestruct // too many options
|
||||
//nolint:exhaustivestruct // too many options
|
||||
opts.Client = &http.Client{
|
||||
Name: fmt.Sprintf("%s/0.1 (+%s)", config.Name, config.Server.GetAddress()),
|
||||
ReadTimeout: DefaultReadTimeout,
|
||||
|
@ -197,7 +197,7 @@ func main() {
|
|||
|
||||
r := router.New()
|
||||
NewApp(opts).Register(r)
|
||||
//nolint: exhaustivestruct// too many options
|
||||
//nolint:exhaustivestruct // too many options
|
||||
r.ServeFilesCustom(path.Join(config.Server.StaticURLPrefix, "{filepath:*}"), &http.FS{
|
||||
Root: config.Server.StaticRootPath,
|
||||
CacheDuration: DefaultCacheDuration,
|
||||
|
@ -211,7 +211,7 @@ func main() {
|
|||
r.GET("/debug/pprof/{filepath:*}", pprofhandler.PprofHandler)
|
||||
}
|
||||
|
||||
//nolint: exhaustivestruct
|
||||
//nolint:exhaustivestruct
|
||||
server := &http.Server{
|
||||
Name: fmt.Sprintf("IndieAuth/0.1 (+%s)", config.Server.GetAddress()),
|
||||
Handler: r.Handler,
|
||||
|
|
Loading…
Reference in New Issue