nuts-foundation/nuts-node

View on GitHub
auth/client/iam/openid4vp.go

Summary

Maintainability
B
6 hrs
Test Coverage
B
84%

Method OpenID4VPClient.RequestRFC021AccessToken has 64 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *OpenID4VPClient) RequestRFC021AccessToken(ctx context.Context, requester did.DID, verifier did.DID, oauthIssuer *url.URL, scopes string,
    useDPoP bool, credentials []vc.VerifiableCredential) (*oauth.TokenResponse, error) {
    iamClient := c.httpClient
    metadata, err := c.AuthorizationServerMetadata(ctx, oauthIssuer.String())
    if err != nil {
Severity: Minor
Found in auth/client/iam/openid4vp.go - About 1 hr to fix

    Method OpenID4VPClient.AccessToken has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func (c *OpenID4VPClient) AccessToken(ctx context.Context, code string, tokenEndpoint string, callbackURI string, clientID did.DID, codeVerifier string, useDPoP bool) (*oauth.TokenResponse, error) {
    Severity: Major
    Found in auth/client/iam/openid4vp.go - About 50 mins to fix

      Method OpenID4VPClient.RequestRFC021AccessToken has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func (c *OpenID4VPClient) RequestRFC021AccessToken(ctx context.Context, requester did.DID, verifier did.DID, oauthIssuer *url.URL, scopes string,
          useDPoP bool, credentials []vc.VerifiableCredential) (*oauth.TokenResponse, error) {
      Severity: Major
      Found in auth/client/iam/openid4vp.go - About 50 mins to fix

        Function NewClient has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func NewClient(wallet holder.Wallet, keyResolver resolver.KeyResolver, jwtSigner nutsCrypto.JWTSigner, ldDocumentLoader ld.DocumentLoader, strictMode bool, httpClientTimeout time.Duration) *OpenID4VPClient {
        Severity: Minor
        Found in auth/client/iam/openid4vp.go - About 45 mins to fix

          Method OpenID4VPClient.PostAuthorizationResponse has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func (c *OpenID4VPClient) PostAuthorizationResponse(ctx context.Context, vp vc.VerifiablePresentation, presentationSubmission pe.PresentationSubmission, verifierResponseURI string, state string) (string, error) {
          Severity: Minor
          Found in auth/client/iam/openid4vp.go - About 35 mins to fix

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

            func (c *OpenID4VPClient) AuthorizationServerMetadata(ctx context.Context, oauthIssuer string) (*oauth.AuthorizationServerMetadata, error) {
                iamClient := c.httpClient
                // the wallet/client acts as authorization server
                metadata, err := iamClient.OAuthAuthorizationServerMetadata(ctx, oauthIssuer)
                if err != nil {
            Severity: Minor
            Found in auth/client/iam/openid4vp.go and 2 other locations - About 30 mins to fix
            auth/client/iam/openid4vp.go on lines 73..81
            auth/client/iam/openid4vp.go on lines 290..297

            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 101.

            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 3 locations. Consider refactoring.
            Open

            func (c *OpenID4VPClient) OpenIdCredentialIssuerMetadata(ctx context.Context, oauthIssuerURI string) (*oauth.OpenIDCredentialIssuerMetadata, error) {
                iamClient := c.httpClient
                rsp, err := iamClient.OpenIdCredentialIssuerMetadata(ctx, oauthIssuerURI)
                if err != nil {
                    return nil, fmt.Errorf("failed to retrieve Openid credential issuer metadata: %w", err)
            Severity: Minor
            Found in auth/client/iam/openid4vp.go and 2 other locations - About 30 mins to fix
            auth/client/iam/openid4vp.go on lines 73..81
            auth/client/iam/openid4vp.go on lines 132..140

            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 101.

            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 3 locations. Consider refactoring.
            Open

            func (c *OpenID4VPClient) ClientMetadata(ctx context.Context, endpoint string) (*oauth.OAuthClientMetadata, error) {
                iamClient := c.httpClient
            
                metadata, err := iamClient.ClientMetadata(ctx, endpoint)
                if err != nil {
            Severity: Minor
            Found in auth/client/iam/openid4vp.go and 2 other locations - About 30 mins to fix
            auth/client/iam/openid4vp.go on lines 132..140
            auth/client/iam/openid4vp.go on lines 290..297

            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 101.

            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

            There are no issues that match your filters.

            Category
            Status