Hi,
I can't reproduce your problem, Can your project steps to reproduce? Thanks.
Hi,
I can't reproduce your problem, Can your project steps to reproduce? Thanks.
Sorry I forgot you used angularUI.
Find environment.ts(and environment.prod.ts)
in your angular project.
oAuthConfig: {
issuer: 'https://localhost:44305',
clientId: 'MyProjectName_App',
dummyClientSecret: '1q2w3e*',
scope: 'MyProjectName Your API Resources Name', // add your API Resources Name
showDebugInformation: true,
oidc: false,
requireHttps: true,
}
Hi,
Find AddOpenIdConnect
method in your client application module class and add the following code:
.AddOpenIdConnect("oidc", options =>
{
--------
// add this line
options.Scope.Add(Your API Resources Name);
--------
});
Like https://github.com/abpframework/abp/blob/dev/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs, Use an ASPNET Core application as the host, and install identity management module and localization management module.
Has your first problem been solved? Please create a new post to discuss. Thanks.
Hi,
I create a simple implementation, but I don't know about AWS-CloudWatch
, I hope I can help you.
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IAuditingStore))]
public class CustomAuditingStore : AuditingStore
{
private readonly LogEventBatch _repo = new LogEventBatch();
private readonly IAmazonCloudWatchLogs _client;
private int _requestCount = 5;
private static readonly Regex InvalidSequenceTokenRegex = new
Regex(@"The given sequenceToken is invalid. The next expected sequenceToken is: (\d+)");
public CustomAuditingStore(
IAuditLogRepository auditLogRepository,
IGuidGenerator guidGenerator,
IUnitOfWorkManager unitOfWorkManager,
IOptions<AbpAuditingOptions> options)
: base(auditLogRepository, guidGenerator, unitOfWorkManager, options)
{
_client = new AmazonCloudWatchLogsClient(..your config);
}
public override async Task SaveAsync(AuditLogInfo auditInfo)
{
AddSingleMessage(JsonConvert.SerializeObject(auditInfo));
await SendMessages();
await base.SaveAsync(auditInfo);
}
private void AddSingleMessage(string message)
{
_repo.AddMessage(new InputLogEvent()
{
Timestamp = DateTime.Now,
Message = message,
});
}
private async Task SendMessages()
{
try
{
//Make sure the log events are in the right order.
_repo._request.LogEvents.Sort((ev1, ev2) => ev1.Timestamp.CompareTo(ev2.Timestamp));
var response = await _client.PutLogEventsAsync(_repo._request).ConfigureAwait(false);
_repo.Reset(response.NextSequenceToken);
_requestCount = 5;
}
catch (InvalidSequenceTokenException ex)
{
//In case the NextSequenceToken is invalid for the last sent message, a new stream would be
//created for the said application.
if (_requestCount > 0)
{
_requestCount--;
var regexResult = InvalidSequenceTokenRegex.Match(ex.Message);
if (regexResult.Success)
{
_repo._request.SequenceToken = regexResult.Groups[1].Value;
await SendMessages().ConfigureAwait(false);
}
}
}
}
}
/// <summary>
/// Class to handle PutLogEvent request and associated parameters.
/// Also has the requisite checks to determine when the object is ready for Transmission.
/// </summary>
public class LogEventBatch
{
public TimeSpan TimeIntervalBetweenPushes { get; private set; }
public int MaxBatchSize { get; private set; }
public bool ShouldSendRequest(int maxQueuedEvents)
{
if (_request.LogEvents.Count == 0)
{
return false;
}
if (_nextPushTime < DateTime.UtcNow)
{
return true;
}
if (maxQueuedEvents <= _request.LogEvents.Count)
{
return true;
}
return false;
}
int _totalMessageSize { get; set; }
DateTime _nextPushTime;
public PutLogEventsRequest _request = new PutLogEventsRequest();
public LogEventBatch(string logGroupName, string streamName, int timeIntervalBetweenPushes, int maxBatchSize)
{
_request.LogGroupName = logGroupName;
_request.LogStreamName = streamName;
TimeIntervalBetweenPushes = TimeSpan.FromSeconds(timeIntervalBetweenPushes);
MaxBatchSize = maxBatchSize;
Reset(null);
}
public LogEventBatch()
{
}
public int CurrentBatchMessageCount
{
get { return this._request.LogEvents.Count; }
}
public bool IsEmpty => _request.LogEvents.Count == 0;
public bool IsSizeConstraintViolated(string message)
{
Encoding unicode = Encoding.Unicode;
int prospectiveLength = _totalMessageSize + unicode.GetMaxByteCount(message.Length);
if (MaxBatchSize < prospectiveLength)
return true;
return false;
}
public void AddMessage(InputLogEvent ev)
{
Encoding unicode = Encoding.Unicode;
_totalMessageSize += unicode.GetMaxByteCount(ev.Message.Length);
_request.LogEvents.Add(ev);
}
public void Reset(string SeqToken)
{
_request.LogEvents.Clear();
_totalMessageSize = 0;
_request.SequenceToken = SeqToken;
_nextPushTime = DateTime.UtcNow.Add(TimeIntervalBetweenPushes);
}
}