Base solution for your next web application

Activities of "mightyit"

Hi ismcagdas

We upgraded from an old version however this issue was present in the old version as well that is why we decided to upgrade. Will send through the log file shortly thanks

Product Version: 11.2.0 Product Type: MVC Product Type: .Net Core

ABP Framework Version: 7.3.0

Hi

We are noticing extremely long request times with the TokenAuth/Authenticate method in our production environment. Authenticate requests are taking 65 seconds to complete with clients using the API.

However when I run a authenticate request via postman it only takes 1.6 seconds. We have other methods exposed to our API which are nowhere near as slow as the authenticate these take under a second to complete.

Our resource usage on the app service is extremely low when these requests take so long to complete so its not a resource bottleneck that is causing the issue.

Any help in this regard would be greatly appreciated.

Hi

I receive a 404 not found error whenever I try to access hyperlinks to Github issues / code samples / documentation from the AspNetZero support forums. Please advise.

@justinp Clear the domain name field

@rnguyen Clear the domain name field

I checked the documentation at https://aspnetboilerplate.com/Pages/Documents/Swagger-UI-Integration

Swagger UI does not render the authorization dialog for bearer token authentication. This seems to be due to abp-specific javascript contained in wwwroot/swagger/ui/index.html, for the onload event, not returning null, in stead of the proper markup for the authorizebtn component.

 configObject.plugins = [
                function (system) {
                    return {
                        components: {
                            authorizeBtn: function () {
                                return null; // <-- Returning null in stead of authorize button markup
                            }
                        }
                    }
                }
            ];

Here is the OAS3 markup that is generated from my API during runtime (shortened)

{
    "openapi": "3.0.1",
    "info": {
        "title": "MyDemo Host API v1",
        "version": "v1"
    },
    "paths": {
        "/api/services/app/Tenant/CreateTenant": {
            "post": {
                "tags": [
                    "Tenant"
                ],
                "operationId": "ApiServicesAppTenantCreatetenantPost",
                "requestBody": {
                    "content": {
                        "application/json-patch+json": {
                            "schema": {
                                "allOf": [
                                    {
                                        "$ref": "#/components/schemas/CreateTenantInput"
                                    }
                                ]
                            }
                        },
                        "application/json": {
                            "schema": {
                                "allOf": [
                                    {
                                        "$ref": "#/components/schemas/CreateTenantInput"
                                    }
                                ]
                            }
                        },
                        "text/json": {
                            "schema": {
                                "allOf": [
                                    {
                                        "$ref": "#/components/schemas/CreateTenantInput"
                                    }
                                ]
                            }
                        },
                        "application/*+json": {
                            "schema": {
                                "allOf": [
                                    {
                                        "$ref": "#/components/schemas/CreateTenantInput"
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "$ref": "#/components/schemas/SwaggerDocResponseWrapper"
                                }
                            },
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SwaggerDocResponseWrapper"
                                }
                            },
                            "text/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SwaggerDocResponseWrapper"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearer": []
                    }
                ]
            }
        }
    },
    "components": {
        "schemas": {
            "CreateTenantInput": {
                "required": [
                    "adminEmailAddress",
                    "name",
                    "tenancyName"
                ],
                "type": "object",
                "properties": {
                    "tenancyName": {
                        "maxLength": 64,
                        "minLength": 0,
                        "pattern": "^[a-zA-Z][a-zA-Z0-9_-]{1,}$",
                        "type": "string"
                    },
                    "name": {
                        "maxLength": 128,
                        "minLength": 0,
                        "type": "string"
                    },
                    "adminEmailAddress": {
                        "maxLength": 256,
                        "minLength": 0,
                        "type": "string",
                        "format": "email"
                    },
                    "adminPassword": {
                        "maxLength": 128,
                        "minLength": 0,
                        "type": "string",
                        "nullable": true
                    },
                    "connectionString": {
                        "maxLength": 1024,
                        "type": "string",
                        "nullable": true
                    },
                    "shouldChangePasswordOnNextLogin": {
                        "type": "boolean"
                    },
                    "sendActivationEmail": {
                        "type": "boolean"
                    },
                    "editionId": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "isActive": {
                        "type": "boolean"
                    },
                    "subscriptionEndDateUtc": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "isInTrialPeriod": {
                        "type": "boolean"
                    },
                    "onSellingPartnerId": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "onSellingPartner": {
                        "allOf": [
                            {
                                "$ref": "#/components/schemas/OnSellingPartnerDto"
                            }
                        ],
                        "nullable": true
                    },
                    "contactPersonFirstName": {
                        "maxLength": 32,
                        "type": "string",
                        "nullable": true
                    },
                    "contactPersonLastName": {
                        "maxLength": 32,
                        "type": "string",
                        "nullable": true
                    },
                    "contactNumber": {
                        "maxLength": 24,
                        "type": "string",
                        "nullable": true
                    },
                    "contactEmail": {
                        "maxLength": 256,
                        "type": "string",
                        "nullable": true
                    },
                    "taxNumber": {
                        "maxLength": 24,
                        "type": "string",
                        "nullable": true
                    },
                    "registeredName": {
                        "maxLength": 256,
                        "type": "string",
                        "nullable": true
                    },
                    "tenantBillingAddress": {
                        "allOf": [
                            {
                                "$ref": "#/components/schemas/TenantBillingAddressInput"
                            }
                        ],
                        "nullable": true
                    }
                },
                "additionalProperties": false
            },
            "ValidationError": {
                "type": "object",
                "properties": {
                    "message": {
                        "type": "string",
                        "nullable": true
                    },
                    "members": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "nullable": true
                    }
                },
                "additionalProperties": false
            },
            "SwaggerDocResponseWrapper": {
                "type": "object",
                "properties": {
                    "result": {
                        "type": "string",
                        "nullable": true
                    },
                    "targetUrl": {
                        "type": "string",
                        "nullable": true
                    },
                    "success": {
                        "type": "boolean"
                    },
                    "error": {
                        "allOf": [
                            {
                                "$ref": "#/components/schemas/ResponseError"
                            }
                        ],
                        "nullable": true
                    },
                    "unauthorizedRequest": {
                        "type": "boolean"
                    },
                    "__Abp": {
                        "type": "boolean"
                    }
                },
                "additionalProperties": false
            },
            "OnSellingPartnerDto": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string",
                        "nullable": true
                    },
                    "isActive": {
                        "type": "boolean"
                    },
                    "registeredName": {
                        "type": "string",
                        "nullable": true
                    },
                    "taxNumber": {
                        "type": "string",
                        "nullable": true
                    },
                    "contactNumber": {
                        "type": "string",
                        "nullable": true
                    },
                    "contactPersonFirstName": {
                        "type": "string",
                        "nullable": true
                    },
                    "contactPersonLastName": {
                        "type": "string",
                        "nullable": true
                    },
                    "contactEmail": {
                        "type": "string",
                        "nullable": true
                    },
                    "id": {
                        "type": "integer",
                        "format": "int32"
                    }
                },
                "additionalProperties": false
            },
            "TenantBillingAddressInput": {
                "type": "object",
                "properties": {
                    "streetAddress": {
                        "maxLength": 256,
                        "minLength": 0,
                        "type": "string",
                        "nullable": true
                    },
                    "region": {
                        "maxLength": 64,
                        "minLength": 0,
                        "type": "string",
                        "nullable": true
                    },
                    "city": {
                        "maxLength": 64,
                        "minLength": 0,
                        "type": "string",
                        "nullable": true
                    },
                    "countryId": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "regionCode": {
                        "maxLength": 6,
                        "minLength": 0,
                        "type": "string",
                        "nullable": true
                    }
                },
                "additionalProperties": false
            },
            "ResponseError": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "message": {
                        "type": "string",
                        "nullable": true
                    },
                    "details": {
                        "type": "string",
                        "nullable": true
                    },
                    "validationErrors": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ValidationError"
                        },
                        "nullable": true
                    }
                },
                "additionalProperties": false
            }
        },
        "securitySchemes": {
            "bearer": {
                "type": "http",
                "description": "Specify the authorization token.",
                "scheme": "bearer",
                "bearerFormat": "JWT"
            }
        }
    },
    "security": [
        {}
    ]
}

This renders correctly when running it through editor.swagger.io (with "Authorize" button and bearer authentication dialog working correctly).

However, it renders incorrectly on my ASPNetZero / ABP solution....

The following version and Nuget package information applies

  • AspNetZero Core MVC & JQuery v10.3.0 (.Net 5)
  • Abp (6.2.0)
  • Swashbuckle.AspNetCore (5.6.3) & Swashbuckle.AspNetCore.NewtonSoft (6.1.4)
  • .Net 5

Have you looked at SqlBulkCopy for doing high-performance bulk inserts?

https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlbulkcopy?view=netframework-4.8

I was able to figure out what the issue was.

I was calling ImpersonatedAuthenticate with an HttpClient for which the bearer token was already set (by calling _httpClient.SetBearerToken(bearerToken);) during authentication. It seems that, if the bearertoken is set for your call, it will resolve the AbpSession.TenantId to the tenantid to which the bearer token applied.

The fix was to new up the HttpClient, so that there is no bearer token set on the subsequent call to ``ImpersonatedAuthenticate`.

Yes, AbpSession.TenantId remains null, even though the Abp.TenantId request header was set to 2.

Here is the session object, serialized as JSON:

{
  "UserId": 1,
  "TenantId": null,
  "ImpersonatorUserId": null,
  "ImpersonatorTenantId": null,
  "MultiTenancy": {
    "IsEnabled": true,
    "IgnoreFeatureCheckForHostUsers": false,
    "Resolvers": [
      "Abp.AspNetCore.MultiTenancy.DomainTenantResolveContributor, Abp.AspNetCore, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null",
      "Abp.AspNetCore.MultiTenancy.HttpHeaderTenantResolveContributor, Abp.AspNetCore, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null",
      "Abp.AspNetCore.MultiTenancy.HttpCookieTenantResolveContributor, Abp.AspNetCore, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null"
    ],
    "TenantIdResolveKey": "Abp.TenantId"
  },
  "MultiTenancySide": 2
}

Here is the request.Headers object, serialized as JSON:

{
  "Connection": [
    "Keep-Alive"
  ],
  "Content-Type": [
    "application/json; charset=utf-8"
  ],
  "Accept": [
    "application/json"
  ],
  "Authorization": [
    "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwibmFtZSI6ImFkbWluIiwiQXNwTmV0LklkZW50aXR5LlNlY3VyaXR5U3RhbXAiOiJRNUpOWlg2NEg0QlZEV1pFVTVCV0hST1QyVzc3UEg1MyIsInJvbGUiOiJBZG1pbiIsImp0aSI6IjJkNmE1YWRmLTVlYjYtNGU3Yy05OTA3LTExZDk3NzFkNjgwZCIsImlhdCI6MTU2NTc2OTY3MywidG9rZW5fdmFsaWRpdHlfa2V5IjoiOGQyNDVhYzctZGM1MC00ZmU1LWEwMzgtNWJjMWIwN2Q1NjM4IiwidXNlcl9pZGVudGlmaWVyIjoiMSIsIm5iZiI6MTU2NTc2OTY3MywiZXhwIjoxNTY1ODU2MDczLCJpc3MiOiJaZW5EZXRlY3QiLCJhdWQiOiJaZW5EZXRlY3QifQ.LG1lcqgRpjmG_Gmh13zwbj-nqejDNAtij5b9HKeU_60"
  ],
  "Host": [
    "localhost:62114"
  ],
  "Content-Length": [
    "0"
  ],
  "Abp.TenantId": [
    "2"
  ],
  "MS-ASPNETCORE-TOKEN": [
    "359ecd4d-4df5-46bd-95b3-630aae1dddbb"
  ],
  "X-Original-Proto": [
    "http"
  ],
  "X-Original-For": [
    "127.0.0.1:58003"
  ]
}

@ismcagdas @ryancyq

See below screenshot which confirms that the Abp.TenantId header is set correctly.

Also, confirming that setting the Abp.TenantId header does not update AbpSession.TenantId, and thus causes the CheckCurrentTenant check to fail and throw the mentioned exception.

So what would cause the AbpSession.TenantId update to fail?

Showing 11 to 20 of 66 entries