Skip to content

Instantly share code, notes, and snippets.

View GeorgDangl's full-sized avatar
😎
Coding

Georg Dangl GeorgDangl

😎
Coding
View GitHub Profile
@GeorgDangl
GeorgDangl / convert_to_ava.py
Last active January 8, 2019 23:39
AVACloud Python Examples to work with GAEB files in Python - https://www.dangl-it.com
# Configure OAuth2 access token for authorization: Dangl.Identity
configuration = avacloud_client_python.Configuration()
configuration.access_token = access_token
api_instance = avacloud_client_python.GaebConversionApi(avacloud_client_python.ApiClient(configuration))
gaeb_file = './GAEBXML_EN.X86' # File path to the input GAEB file
# First, the AVA Project is generated
try:
# Converts GAEB files to Dangl.AVA projects
@GeorgDangl
GeorgDangl / HttpStatusCode.cs
Last active September 30, 2019 23:32
Fixing NSwag issue with duplicated enum values in the generated Swagger document, https://blog.dangl.me/archive/remove-duplicate-enum-entries-in-swagger-documents-with-nswag-in-aspnet-core/
public enum HttpStatusCode
{
/* Excerpt from System.Net.HttpStatusCode */
RedirectKeepVerb = 307,
TemporaryRedirect = 307
}
@GeorgDangl
GeorgDangl / project.csproj
Created November 21, 2018 17:07
Use the new GeneratePathProperty in .NET SDK based csproj files
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Include="$(PkgXbim_Geometry)\build\x64\Xbim.Geometry.Engine64.dll">
<Link>x64\Xbim.Geometry.Engine64.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@GeorgDangl
GeorgDangl / JwtSetup.cs
Created November 19, 2018 07:05
Multiple JWT authorities in ASP.NET Core
services.AddAuthentication()
.AddJwtBearer(AuthenticationConstants.JWT_BASE_SCHEME, jwtBearerOptions =>
{
jwtBearerOptions.Authority = JwtBaseUri;
jwtBearerOptions.Audience = RequiredScope;
})
.AddJwtBearer(AuthenticationConstants.JWT_FALLBACK_SCHEME, jwtBearerOptions =>
{
jwtBearerOptions.Authority = JwtFallbackBaseUri;
jwtBearerOptions.Audience = RequiredScope;
@GeorgDangl
GeorgDangl / getAccessToken.js
Last active February 1, 2019 12:26
AVACloud JavaScript Examples - https://www.dangl-it.com
// This is the Dangl.Identity OpenID token endpoint
const danglIdentityTokenEndpoint = 'https://identity.dangl-it.com/connect/token';
let globalAccessToken;
// This function retrieves the JWT Token and stores it in an Html input field and in a global variable
async function getAccessToken(clientId, clientSecret, tokenFormFieldId) {
// This is an OpenID Client Credentials grant request
const clientCredentialsRequest = new Promise(function (resolve, reject) {
const requestHeaders = new Headers();
requestHeaders.append('Authorization', 'Basic ' + btoa(clientId + ':' + clientSecret));
@GeorgDangl
GeorgDangl / Swap.cs
Last active November 13, 2018 19:49
Using Microsoft.Azure.Management.Fluent to swap App Service staging and production slots - used with AVACloud, see https://blog.dangl.me/archive/deploy-to-azure-app-service-with-no-downtime-by-using-staging-slots/
if (PublishEnvironmentName == "Production")
{
var azureCredentials = SdkContext.AzureCredentialsFactory
.FromServicePrincipal(AzureServicePrincipalClientId,
AzureServicePrincipalClientSecret,
AzureServicePrincipalTenantId,
AzureEnvironment.AzureGlobalCloud);
IAzure azure = Azure.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(azureCredentials)
[HttpGet("")]
[LightQuery]
[Authorize(Policy = DanglIdentityConstants.Authorization.AUTHENTICATION_CONNECTOR_OR_ADMIN_POLICY_NAME)]
[NSwag.Annotations.SwaggerResponse((int)HttpStatusCode.OK, typeof(PaginationResult<ClientGet>))]
[NSwag.Annotations.SwaggerResponse((int)HttpStatusCode.OK, typeof(IEnumerable<ClientGet>))]
public IActionResult GetAllClients(string filter = null)
{
var clientsQuery = _identityServerClientsRepository.GetAllClients()
.ProjectTo<ClientGet>();
if (!string.IsNullOrWhiteSpace(filter))
@GeorgDangl
GeorgDangl / AppEntry.ts
Last active February 1, 2019 12:43
AVACloud Node Examples - www.dangl-it.com
// App main entry point
(async () => {
await getOAuth2AccessToken();
await executeAvaCloudExample();
})();
async function executeAvaCloudExample() {
if (!accessToken) {
console.log('No access token, exiting app.');
return;
@GeorgDangl
GeorgDangl / AuthSetup.java
Last active April 18, 2019 10:18
AVACloud Java Examples - www.dangl-it.com
private static void executeAvaCloudExample(String[] args) {
String clientId = args[0];
String clientSecret = args[1];
String gaebFilePath = args[2];
String bearerToken;
try {
bearerToken = DanglIdentityUtils.getBearerToken(clientId, clientSecret);
} catch (IOException e) {
System.out.println("IO Exception while obtaining access token:");
System.out.println(e.toString());
@GeorgDangl
GeorgDangl / GAEBX83_DE.xml
Last active July 25, 2018 18:48
Dangl.AVA & Dangl.GAEB Tendering Process
<Item ID="ID_cc1077f7-9618-46be-af53-4b500acfefb6" RNoPart="02" RNoIndex="5">
<Qty>240</Qty>
<QU>m²</QU>
<Description>
<OutlineText>
<OutlTSA>No</OutlTSA>
<OutlTxt>
<TextOutlTxt>
<span>Wand, 20cm, Stahlbeton</span>
</TextOutlTxt>