mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
refactor: fix linter directives for go 1.19 and golangci-lint 1.48.0 (#3798)
This commit is contained in:
parent
c585e19499
commit
2d26b4e115
|
@ -29,7 +29,7 @@ func (suite *NotifierSuite) SetupTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Common Tests.
|
Common Tests.
|
||||||
*/
|
*/
|
||||||
func (suite *NotifierSuite) TestShouldEnsureAtLeastSMTPOrFilesystemIsProvided() {
|
func (suite *NotifierSuite) TestShouldEnsureAtLeastSMTPOrFilesystemIsProvided() {
|
||||||
ValidateNotifier(&suite.config, suite.validator)
|
ValidateNotifier(&suite.config, suite.validator)
|
||||||
|
@ -69,7 +69,7 @@ func (suite *NotifierSuite) TestShouldEnsureEitherSMTPOrFilesystemIsProvided() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SMTP Tests.
|
SMTP Tests.
|
||||||
*/
|
*/
|
||||||
func (suite *NotifierSuite) TestSMTPShouldSetTLSDefaults() {
|
func (suite *NotifierSuite) TestSMTPShouldSetTLSDefaults() {
|
||||||
ValidateNotifier(&suite.config, suite.validator)
|
ValidateNotifier(&suite.config, suite.validator)
|
||||||
|
@ -146,7 +146,7 @@ func (suite *NotifierSuite) TestSMTPShouldEnsureSenderIsProvided() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
File Tests.
|
File Tests.
|
||||||
*/
|
*/
|
||||||
func (suite *NotifierSuite) TestFileShouldEnsureFilenameIsProvided() {
|
func (suite *NotifierSuite) TestFileShouldEnsureFilenameIsProvided() {
|
||||||
suite.config.SMTP = nil
|
suite.config.SMTP = nil
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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{
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -9,12 +9,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TestShouldOnlyMarshalPeriodAndDigitsAndAbsolutelyNeverSecret.
|
TestShouldOnlyMarshalPeriodAndDigitsAndAbsolutelyNeverSecret.
|
||||||
This test is vital to ensuring the TOTP configuration is marshalled correctly. If encoding/json suddenly changes
|
This test is vital to ensuring the TOTP configuration is marshalled correctly. If encoding/json suddenly changes
|
||||||
upstream and the json tag value of '-' doesn't exclude the field from marshalling then this test will pickup this
|
upstream and the json tag value of '-' doesn't exclude the field from marshalling then this test will pickup this
|
||||||
issue prior to code being shipped.
|
issue prior to code being shipped.
|
||||||
|
|
||||||
For this reason it's essential that the marshalled object contains all values populated, especially the secret.
|
For this reason it's essential that the marshalled object contains all values populated, especially the secret.
|
||||||
*/
|
*/
|
||||||
func TestShouldOnlyMarshalPeriodAndDigitsAndAbsolutelyNeverSecret(t *testing.T) {
|
func TestShouldOnlyMarshalPeriodAndDigitsAndAbsolutelyNeverSecret(t *testing.T) {
|
||||||
object := TOTPConfiguration{
|
object := TOTPConfiguration{
|
||||||
|
|
|
@ -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 {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user