Skip to content

Instantly share code, notes, and snippets.

View kkadir's full-sized avatar
💭
FE Hell

Kadir Kılıçoğlu kkadir

💭
FE Hell
View GitHub Profile
@kkadir
kkadir / SampleClient.cs
Last active March 1, 2024 11:00
Sample Receive and Push
using System;
using System.Collections.Generic;
using Gevasys.DataCore.Client;
using Gevasys.DataCore.Core;
using Gevasys.DataCore.Core.Protocol;
using Gevasys.DataCore.Core.Protocol.Binary;
using Gevasys.DataCore.Core.Protocol.Binary.Decoding;
using Gevasys.DataCore.Tools.Protocol;
using Gevasys.DataCore.RequestData.ProtoBuf.V2;
@kkadir
kkadir / importer.q
Created March 19, 2020 21:57
Importer utility function in Q
\d .importer
fetch_data:{[table_names;batch_size;data_date]
/ (1) Open remote connection
h::hopen `$":redacted:redacted:redacted";
/ (2) Set arguments
tabs:enlist table_names;
bsize::batch_size;
dday::data_date;
@kkadir
kkadir / Utility.cs
Created March 3, 2020 18:35
Commont methods.
using Microsoft.AspNetCore.Authorization;
using System;
using System.Linq;
namespace CustomPolicyProvidersDemo.Authorization
{
public static class Utility
{
public static void Succeed(AuthorizationHandlerContext context, Guid identifier)
{
@kkadir
kkadir / RolesAuthorizationHandler.cs
Last active March 3, 2020 18:34
The RolesAuthorizationHandler custom implementation
using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging;
namespace CustomPolicyProvidersDemo.Authorization
{
public class RolesAuthorizationHandler : AuthorizationHandler<RolesRequirement>
@kkadir
kkadir / ScopesAuthorizationHandler.cs
Last active March 3, 2020 18:34
The ScopesAuthorizationHandler custom implementation
using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging;
namespace CustomPolicyProvidersDemo.Authorization
{
public class ScopesAuthorizationHandler : AuthorizationHandler<ScopesRequirement>
@kkadir
kkadir / PermissionsAuthorizationHandler.cs
Last active March 3, 2020 18:33
The PermissionsAuthorizationHandler custom implementation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging;
namespace CustomPolicyProvidersDemo.Authorization
{
@kkadir
kkadir / TruthTable.csv
Created March 3, 2020 11:41
The Enigmatic Truth Table of Authorization Handlers.
H1 H2 HN Result
1 N/A N/A Success
0 1 N/A Success
0 0 1 Success
0 0 0 Fail
@kkadir
kkadir / PermissionsPolicyProvider.cs
Last active March 3, 2020 18:24
The custom policy provider.
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Options;
namespace CustomPolicyProvidersDemo.Authorization
{
public class PermissionsPolicyProvider : IAuthorizationPolicyProvider
{
@kkadir
kkadir / PermissionsRequirement.cs
Last active March 3, 2020 18:21
The requirements for our custom policy providers
using System;
using Microsoft.AspNetCore.Authorization;
namespace CustomPolicyProvidersDemo.Authorization
{
public interface IIdentifiable
{
Guid Identifier { get; }
}
@kkadir
kkadir / SampleAttributeUsage.cs
Created March 3, 2020 10:22
A sample usage of the custom PermissionsAttribute.
...
...
[Permissions(Permissions = new[] { "Read", "Write" },
Roles = new[] { "Admin"})]
[HttpGet("{id}")]
public async Task<IActionResult> GetAsync(int id)
{
...
}