refactor: fix linter directives for go 1.19 and golangci-lint 1.48.0 (#3798)

pull/3800/head
Amir Zarrinkafsh 2022-08-07 11:24:00 +10:00 committed by GitHub
parent c585e19499
commit 2d26b4e115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 26 deletions

View File

@ -11,6 +11,7 @@ import (
) )
// FirstFactorPOST is the handler performing the first factory. // FirstFactorPOST is the handler performing the first factory.
//
//nolint:gocyclo // TODO: Consider refactoring time permitting. //nolint:gocyclo // TODO: Consider refactoring time permitting.
func FirstFactorPOST(delayFunc middlewares.TimingAttackDelayFunc) middlewares.RequestHandler { func FirstFactorPOST(delayFunc middlewares.TimingAttackDelayFunc) middlewares.RequestHandler {
return func(ctx *middlewares.AutheliaCtx) { return func(ctx *middlewares.AutheliaCtx) {

View File

@ -346,10 +346,13 @@ func (s *FirstFactorRedirectionSuite) TearDownTest() {
} }
// When: // When:
//
// 1/ the target url is unknown // 1/ the target url is unknown
// 2/ two_factor is disabled (no policy is set to two_factor) // 2/ two_factor is disabled (no policy is set to two_factor)
// 3/ default_redirect_url is provided // 3/ default_redirect_url is provided
//
// Then: // Then:
//
// the user should be redirected to the default url. // the user should be redirected to the default url.
func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenNoTargetURLProvidedAndTwoFactorDisabled() { func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenNoTargetURLProvidedAndTwoFactorDisabled() {
s.mock.Ctx.Request.SetBodyString(`{ s.mock.Ctx.Request.SetBodyString(`{
@ -365,10 +368,13 @@ func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenNoTarget
} }
// When: // When:
//
// 1/ the target url is unsafe // 1/ the target url is unsafe
// 2/ two_factor is disabled (no policy is set to two_factor) // 2/ two_factor is disabled (no policy is set to two_factor)
// 3/ default_redirect_url is provided // 3/ default_redirect_url is provided
//
// Then: // Then:
//
// the user should be redirected to the default url. // the user should be redirected to the default url.
func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenURLIsUnsafeAndTwoFactorDisabled() { func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenURLIsUnsafeAndTwoFactorDisabled() {
s.mock.Ctx.Request.SetBodyString(`{ s.mock.Ctx.Request.SetBodyString(`{
@ -386,8 +392,11 @@ func (s *FirstFactorRedirectionSuite) TestShouldRedirectToDefaultURLWhenURLIsUns
} }
// When: // When:
//
// 1/ two_factor is enabled (default policy) // 1/ two_factor is enabled (default policy)
//
// Then: // Then:
//
// the user should receive 200 without redirection URL. // the user should receive 200 without redirection URL.
func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenNoTargetURLProvidedAndTwoFactorEnabled() { func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenNoTargetURLProvidedAndTwoFactorEnabled() {
s.mock.Ctx.Providers.Authorizer = authorization.NewAuthorizer(&schema.Configuration{ s.mock.Ctx.Providers.Authorizer = authorization.NewAuthorizer(&schema.Configuration{
@ -409,8 +418,11 @@ func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenNoTargetURLProvidedA
} }
// When: // When:
//
// 1/ two_factor is enabled (some rule) // 1/ two_factor is enabled (some rule)
//
// Then: // Then:
//
// the user should receive 200 without redirection URL. // the user should receive 200 without redirection URL.
func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenUnsafeTargetURLProvidedAndTwoFactorEnabled() { func (s *FirstFactorRedirectionSuite) TestShouldReply200WhenUnsafeTargetURLProvidedAndTwoFactorEnabled() {
s.mock.Ctx.Providers.Authorizer = authorization.NewAuthorizer(&schema.Configuration{ s.mock.Ctx.Providers.Authorizer = authorization.NewAuthorizer(&schema.Configuration{

View File

@ -48,8 +48,9 @@ func OpenIDConnectConsentGET(ctx *middlewares.AutheliaCtx) {
} }
} }
//nolint:gocyclo
// OpenIDConnectConsentPOST handles consent responses for OpenID Connect. // OpenIDConnectConsentPOST handles consent responses for OpenID Connect.
//
//nolint:gocyclo // TODO: Consider refactoring time permitting.
func OpenIDConnectConsentPOST(ctx *middlewares.AutheliaCtx) { func OpenIDConnectConsentPOST(ctx *middlewares.AutheliaCtx) {
var ( var (
consentID uuid.UUID consentID uuid.UUID

View File

@ -156,6 +156,7 @@ type ConsentPostResponseBody struct {
/* /*
CommonDiscoveryOptions represents the discovery options used in both OAuth 2.0 and OpenID Connect. CommonDiscoveryOptions represents the discovery options used in both OAuth 2.0 and OpenID Connect.
See Also: See Also:
OpenID Connect Discovery: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata OpenID Connect Discovery: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
OAuth 2.0 Discovery: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-discovery-10#section-2 OAuth 2.0 Discovery: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-discovery-10#section-2
*/ */
@ -514,6 +515,7 @@ type OpenIDConnectDiscoveryOptions struct {
// OpenIDConnectFrontChannelLogoutDiscoveryOptions represents the discovery options specific to // OpenIDConnectFrontChannelLogoutDiscoveryOptions represents the discovery options specific to
// OpenID Connect Front-Channel Logout functionality. // OpenID Connect Front-Channel Logout functionality.
// See Also: // See Also:
//
// OpenID Connect Front-Channel Logout: https://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout // OpenID Connect Front-Channel Logout: https://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout
type OpenIDConnectFrontChannelLogoutDiscoveryOptions struct { type OpenIDConnectFrontChannelLogoutDiscoveryOptions struct {
/* /*
@ -533,6 +535,7 @@ type OpenIDConnectFrontChannelLogoutDiscoveryOptions struct {
// OpenIDConnectBackChannelLogoutDiscoveryOptions represents the discovery options specific to // OpenIDConnectBackChannelLogoutDiscoveryOptions represents the discovery options specific to
// OpenID Connect Back-Channel Logout functionality. // OpenID Connect Back-Channel Logout functionality.
// See Also: // See Also:
//
// OpenID Connect Back-Channel Logout: https://openid.net/specs/openid-connect-backchannel-1_0.html#BCSupport // OpenID Connect Back-Channel Logout: https://openid.net/specs/openid-connect-backchannel-1_0.html#BCSupport
type OpenIDConnectBackChannelLogoutDiscoveryOptions struct { type OpenIDConnectBackChannelLogoutDiscoveryOptions struct {
/* /*

View File

@ -133,7 +133,7 @@ func (p *SQLProvider) SchemaMigrate(ctx context.Context, up bool, version int) (
return p.schemaMigrate(ctx, currentVersion, version) return p.schemaMigrate(ctx, currentVersion, version)
} }
//nolint: gocyclo //nolint:gocyclo // TODO: Consider refactoring time permitting.
func (p *SQLProvider) schemaMigrate(ctx context.Context, prior, target int) (err error) { func (p *SQLProvider) schemaMigrate(ctx context.Context, prior, target int) (err error) {
migrations, err := loadMigrations(p.name, prior, target) migrations, err := loadMigrations(p.name, prior, target)
if err != nil { if err != nil {

View File

@ -32,9 +32,8 @@ var BuildNumber = "0"
// Version returns the Authelia version. // Version returns the Authelia version.
// //
// The format of the string is dependent on the values in BuildState. If tagged and clean are present it returns the // The format of the string is dependent on the values in BuildState. If tagged and clean are present it returns the
// BuildTag i.e. v1.0.0. If dirty and tagged are present it returns <BuildTag>-dirty. Otherwise the following is the // BuildTag i.e. v1.0.0. If dirty and tagged are present it returns <BuildTag>-dirty. Otherwise, the following is the
// format: untagged-<BuildTag>-dirty-<BuildExtra> (<BuildBranch>, <BuildCommit>). // format: untagged-<BuildTag>-dirty-<BuildExtra> (<BuildBranch>, <BuildCommit>).
//
func Version() (versionString string) { func Version() (versionString string) {
return version(BuildTag, BuildState, BuildCommit, BuildBranch, BuildExtra) return version(BuildTag, BuildState, BuildCommit, BuildBranch, BuildExtra)
} }