View AspNetIdentity-SQL-Scripts.sql
/* | |
SQL DDL scripts generated using | |
dotnet ef database update | |
for the IdentityServer4.Samples 6_AspNetIdentity quick start. This was run for | |
commit 0a7400a2ade8c149b3feb08a05bf4423d19ac08c in that repository. It references | |
- IdentityServer4.AspNetIdentity 2.0.0 including | |
- Microsoft.AspNetCore.Identity (>= 2.0.1) |
View example.js
// Please avoid "password" flow at all cost, it has been officially deprecated | |
// https://tools.ietf.org/html/draft-ietf-oauth-security-topics-15#section-2.4 | |
// But, if you must use it, here's a simple way to do so: | |
async function getTokenResponse(clientId, identityServerUrl, username, password) { | |
const response = await fetch(identityServerUrl + "/connect/token", { | |
method: "POST", | |
headers: { | |
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', | |
}, |
View localhost-ssl.conf
# Based on https://stackoverflow.com/a/59702094/419956 by user @chrisvdb cc-by-sa rev 2020.5.28.36925 | |
# Not currently working for me on Ubuntu 20.04 though! | |
[req] | |
default_bits = 2048 | |
default_keyfile = localhost.key | |
distinguished_name = req_distinguished_name | |
req_extensions = req_ext | |
x509_extensions = v3_ca |
View ngb-momentjs-adapter.ts
import { NgbDateAdapter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap'; | |
import { Injectable } from '@angular/core'; | |
import * as moment from 'moment'; | |
// Might need to polyfill depending on needed browser support... | |
const isInt = Number.isInteger; | |
@Injectable() | |
export class NgbMomentjsAdapter extends NgbDateAdapter<moment.Moment> { |
View destroyable.component.spec.ts
import { Subject } from 'rxjs'; | |
import { Destroyable } from './destroyable.component'; | |
class TestableDestroyable extends Destroyable { } | |
describe('Destroyable', () => { | |
it('should construct with observable', () => { | |
const component = new TestableDestroyable(); | |
expect(component.destroyed$ instanceof Subject).toBeTruthy(); | |
}); |
View Foo.Tests.csproj
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>netcoreapp2.2</TargetFramework> | |
<IsPackable>false</IsPackable> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.AspNetCore.App" /> | |
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" /> |
View angular-oauth2-oidc-extra-logging-snippet.ts
import { OAuthErrorEvent } from 'angular-oauth2-oidc'; | |
// ... | |
this.authService.events.subscribe(event => { | |
if (event instanceof OAuthErrorEvent) { | |
console.error(event); | |
} else { | |
console.warn(event); | |
} |
View choco-install.ps1
choco install adobereader -y | |
choco install googlechrome -y | |
choco install firefox -y | |
choco install 7zip -y | |
choco install notepadplusplus -y | |
choco install git -y | |
choco install putty -y | |
choco install nodejs -y | |
choco install skype -y | |
choco install sysinternals -y |
View decorated-oauth-storage.ts
// Usage: | |
// { provide: OAuthStorage, useValue: decoratedStorage }, | |
const decoratedStorage: OAuthStorage = { | |
getItem(key) { | |
const data = localStorage.getItem(key); | |
console.warn('get', key, data ? data.substring(0, 25) : data); | |
return data; | |
}, | |
setItem(key, data) { |
View NgbDateStringParserFormatter.ts
// Formatter using "dd-MM-yyyy" string format: | |
// See: https://ng-bootstrap.github.io/#/components/datepicker/api#NgbDateParserFormatter | |
// | |
export class NgbDateStringParserFormatter extends NgbDateParserFormatter { | |
parse(value: string): NgbDateStruct { | |
if (!value) { return null; } | |
const parts = value.trim().split('-'); | |
return { |
NewerOlder