ory-am/hydra

View on GitHub

Showing 849 of 849 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        {
            name: "Generate ES256",
            args: args{
                ctx: context.TODO(),
                set: x.OpenIDConnectKeyName,
Severity: Major
Found in hsm/manager_hsm_test.go and 1 other location - About 2 hrs to fix
hsm/manager_hsm_test.go on lines 264..279

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 211.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

func (o *AcceptOAuth2LoginRequest) UnmarshalJSON(data []byte) (err error) {
    // This validates that all required properties are included in the JSON object
    // by unmarshalling the object into a generic map with string keys and checking
    // that every required field exists as a key in the generic map.
    requiredProperties := []string{
Severity: Major
Found in internal/httpclient/model_accept_o_auth2_login_request.go and 4 other locations - About 2 hrs to fix
internal/httpclient/model_generic_error.go on lines 347..382
internal/httpclient/model_introspected_o_auth2_token.go on lines 568..603
internal/httpclient/model_o_auth2_consent_request.go on lines 526..561
internal/httpclient/model_o_auth2_redirect_to.go on lines 87..122

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 211.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

func (o *IntrospectedOAuth2Token) UnmarshalJSON(data []byte) (err error) {
    // This validates that all required properties are included in the JSON object
    // by unmarshalling the object into a generic map with string keys and checking
    // that every required field exists as a key in the generic map.
    requiredProperties := []string{
Severity: Major
Found in internal/httpclient/model_introspected_o_auth2_token.go and 4 other locations - About 2 hrs to fix
internal/httpclient/model_accept_o_auth2_login_request.go on lines 382..417
internal/httpclient/model_generic_error.go on lines 347..382
internal/httpclient/model_o_auth2_consent_request.go on lines 526..561
internal/httpclient/model_o_auth2_redirect_to.go on lines 87..122

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 211.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

OAuth2ConsentRequestOpenIDConnectContext has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

type OAuth2ConsentRequestOpenIDConnectContext struct {
    // ACRValues is the Authentication AuthorizationContext Class Reference requested in the OAuth 2.0 Authorization request. It is a parameter defined by OpenID Connect and expresses which level of authentication (e.g. 2FA) is required.  OpenID Connect defines it as follows: > Requested Authentication AuthorizationContext Class Reference values. Space-separated string that specifies the acr values that the Authorization Server is being requested to use for processing this Authentication Request, with the values appearing in order of preference. The Authentication AuthorizationContext Class satisfied by the authentication performed is returned as the acr Claim Value, as specified in Section 2. The acr Claim is requested as a Voluntary Claim by this parameter.
    AcrValues []string `json:"acr_values,omitempty"`
    // Display is a string value that specifies how the Authorization Server displays the authentication and consent user interface pages to the End-User. The defined values are: page: The Authorization Server SHOULD display the authentication and consent UI consistent with a full User Agent page view. If the display parameter is not specified, this is the default display mode. popup: The Authorization Server SHOULD display the authentication and consent UI consistent with a popup User Agent window. The popup User Agent window should be of an appropriate size for a login-focused dialog and should not obscure the entire window that it is popping up over. touch: The Authorization Server SHOULD display the authentication and consent UI consistent with a device that leverages a touch interface. wap: The Authorization Server SHOULD display the authentication and consent UI consistent with a \"feature phone\" type display.  The Authorization Server MAY also attempt to detect the capabilities of the User Agent and present an appropriate display.
    Display *string `json:"display,omitempty"`

    ErrorOAuth2 has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type ErrorOAuth2 struct {
        // Error
        Error *string `json:"error,omitempty"`
        // Error Debug Information  Only available in dev mode.
        ErrorDebug *string `json:"error_debug,omitempty"`
    Severity: Minor
    Found in internal/httpclient/model_error_o_auth2.go - About 2 hrs to fix

      DefaultStrategy has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type DefaultStrategy struct {
          c *config.DefaultProvider
          r InternalRegistry
      }
      Severity: Minor
      Found in consent/strategy_default.go - About 2 hrs to fix

        OAuth2ConsentSessionExpiresAt has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type OAuth2ConsentSessionExpiresAt struct {
            AccessToken   *time.Time `json:"access_token,omitempty"`
            AuthorizeCode *time.Time `json:"authorize_code,omitempty"`
            IdToken       *time.Time `json:"id_token,omitempty"`
            ParContext    *time.Time `json:"par_context,omitempty"`
        Severity: Minor
        Found in internal/httpclient/model_o_auth2_consent_session_expires_at.go - About 2 hrs to fix

          RejectOAuth2Request has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type RejectOAuth2Request struct {
              // The error should follow the OAuth2 error format (e.g. `invalid_request`, `login_required`).  Defaults to `request_denied`.
              Error *string `json:"error,omitempty"`
              // Debug contains information to help resolve the problem as a developer. Usually not exposed to the public but only in the server logs.
              ErrorDebug *string `json:"error_debug,omitempty"`
          Severity: Minor
          Found in internal/httpclient/model_reject_o_auth2_request.go - About 2 hrs to fix

            RFC6749ErrorJson has 22 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type RFC6749ErrorJson struct {
                Error            *string `json:"error,omitempty"`
                ErrorDebug       *string `json:"error_debug,omitempty"`
                ErrorDescription *string `json:"error_description,omitempty"`
                ErrorHint        *string `json:"error_hint,omitempty"`
            Severity: Minor
            Found in internal/httpclient/model_rfc6749_error_json.go - About 2 hrs to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      testhelpers.NewLoginConsentUI(t, reg.Config(), func(w http.ResponseWriter, r *http.Request) {
                          vr, _, err := adminClient.OAuth2Api.RejectOAuth2LoginRequest(context.Background()).
                              LoginChallenge(r.URL.Query().Get("login_challenge")).
                              RejectOAuth2Request(hydra.RejectOAuth2Request{
                                  Error:            pointerx.String(fosite.ErrInteractionRequired.ErrorField),
              Severity: Major
              Found in consent/strategy_oauth_test.go and 1 other location - About 2 hrs to fix
              consent/strategy_oauth_test.go on lines 188..198

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 210.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                          func(w http.ResponseWriter, r *http.Request) {
                              vr, _, err := adminClient.OAuth2Api.RejectOAuth2ConsentRequest(context.Background()).
                                  ConsentChallenge(r.URL.Query().Get("consent_challenge")).
                                  RejectOAuth2Request(hydra.RejectOAuth2Request{
                                      Error:            pointerx.String(fosite.ErrInteractionRequired.ErrorField),
              Severity: Major
              Found in consent/strategy_oauth_test.go and 1 other location - About 2 hrs to fix
              consent/strategy_oauth_test.go on lines 157..168

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 210.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function TestHelperCreateGetUpdateDeleteClientNext has 83 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func TestHelperCreateGetUpdateDeleteClientNext(t *testing.T, m Storage, networks []uuid.UUID) {
                  ctx := context.Background()
              
                  resources := map[uuid.UUID][]Client{}
                  for k := range networks {
              Severity: Major
              Found in client/manager_test_helpers.go - About 2 hrs to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        t.Run("case=login-timeout", func(t *testing.T) {
                            ctx := context.Background()
                            jt := testhelpers.NewConsentJanitorTestHelper(t.Name())
                            reg, err := jt.GetRegistry(ctx, t.Name())
                            require.NoError(t, err)
                Severity: Major
                Found in cmd/cli/handler_janitor_test.go and 1 other location - About 2 hrs to fix
                cmd/cli/handler_janitor_test.go on lines 125..145

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 209.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        t.Run("case=consent-timeout", func(t *testing.T) {
                            ctx := context.Background()
                            jt := testhelpers.NewConsentJanitorTestHelper(t.Name())
                            reg, err := jt.GetRegistry(ctx, t.Name())
                            require.NoError(t, err)
                Severity: Major
                Found in cmd/cli/handler_janitor_test.go and 1 other location - About 2 hrs to fix
                cmd/cli/handler_janitor_test.go on lines 103..123

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 209.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        {
                            GrantTypes: []string{
                                "refresh_token",
                            },
                            Request: fosite.Request{
                Severity: Major
                Found in internal/testhelpers/janitor_test_helper.go and 1 other location - About 2 hrs to fix
                internal/testhelpers/janitor_test_helper.go on lines 731..746

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 207.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        {
                            GrantTypes: []string{
                                "refresh_token",
                            },
                            Request: fosite.Request{
                Severity: Major
                Found in internal/testhelpers/janitor_test_helper.go and 1 other location - About 2 hrs to fix
                internal/testhelpers/janitor_test_helper.go on lines 747..762

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 207.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Function createPlan has 82 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func createPlan(t *testing.T, extra url.Values, isParallel bool) {
                    planName := extra.Get("planName")
                    if stringslice.Has(skipWhenShort, planName) && testing.Short() {
                        t.Skipf("Skipping test plan '%s' because short tests", planName)
                        return
                Severity: Major
                Found in test/conformance/run_test.go - About 2 hrs to fix

                  Function run has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const run = (client) => {
                        const codeChallenge = "QeNVR-BHuB6I2d0HycQzp2qUNNKi_-5QoR4fQSifLH0"
                        const codeVerifier =
                          "ZmRrenFxZ3pid3A0T0xqY29falJNUS5lWlY4SDBxS182U21uQkhjZ3UuOXpnd3NOak56d2lLMTVYemNNdHdNdlE5TW03WC1RZUlaM0N5R2FhdGRpNW1oVGhjbzVuRFBD"
                        const state = prng()
                  Severity: Major
                  Found in cypress/support/commands.js - About 2 hrs to fix

                    Method RegistrySQL.Init has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (m *RegistrySQL) Init(
                        ctx context.Context,
                        skipNetworkInit bool,
                        migrate bool,
                        ctxer contextx.Contextualizer,
                    Severity: Minor
                    Found in driver/registry_sql.go - About 2 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Similar blocks of code found in 3 locations. Consider refactoring.
                    Open

                            cy.request(`${Cypress.env("client_url")}/openid/userinfo`, {
                              failOnStatusCode: false,
                            })
                              .its("body")
                              .then((response) => {
                    Severity: Major
                    Found in cypress/integration/openid/revoke.js and 2 other locations - About 2 hrs to fix
                    cypress/integration/openid/revoke.js on lines 40..46
                    cypress/integration/openid/revoke.js on lines 64..70

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 80.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language