Skip to content

Instantly share code, notes, and snippets.

name: Deploy to Azure
on:
push:
branches:
- master
env:
AZURE_WEBAPP_NAME: application-api
AZURE_WEBAPP_PACKAGE_PATH: './src/Application.Api/bin/Release/netcoreapp3.0'
[
{
"fileName": "1.png",
"isPrimary": true,
"isForLight": true,
"isForDark": false,
"altitude": 27.95,
"azimuth": 279.66
},
{
import Foundation
import AppKit
import AVFoundation
extension NSImage {
@objc var CGImage: CGImage? {
get {
guard let imageData = self.tiffRepresentation else { return nil }
guard let sourceData = CGImageSourceCreateWithData(imageData as CFData, nil) else { return nil }
return CGImageSourceCreateImageAtIndex(sourceData, 0, nil)
import Foundation
import AppKit
import AVFoundation
extension NSImage {
@objc var CGImage: CGImage? {
get {
guard let imageData = self.tiffRepresentation else { return nil }
guard let sourceData = CGImageSourceCreateWithData(imageData as CFData, nil) else { return nil }
return CGImageSourceCreateImageAtIndex(sourceData, 0, nil)
public class SameAuthorRequirement : AuthorizationRequirementProtocol {
public init() {
}
}
public func get(request: HTTPRequest, response: HTTPResponse) {
do {
guard let stringId = request.urlVariables["id"],
let id = UUID(uuidString: stringId) else {
return response.sendBadRequestError()
}
guard let task = try self.tasksService.get(byId: id) else {
return response.sendNotFoundError()
}
import Foundation
public class TaskAuthorizationHandler : AuthorizationHandlerProtocol {
public var requirementType: AuthorizationRequirementProtocol.Type = SameAuthorRequirement.self
public var resourceType: EntityProtocol.Type = Task.self
public func handle(user: UserCredentials,
resource: EntityProtocol,
requirement: AuthorizationRequirementProtocol) throws -> Bool {
// Resource-based authorization.
let authorizationService = try! container.resolve() as AuthorizationServiceProtocol
authorizationService.add(policy: "EditPolicy", requirements: [SameAuthorRequirement()])
public func get(request: HTTPRequest, response: HTTPResponse) {
do {
guard let stringId = request.urlVariables["id"], let id = UUID(uuidString: stringId) else {
return response.sendBadRequestError()
}
guard let task = try self.tasksService.get(byId: id) else {
return response.sendNotFoundError()
}
// Resource-based authorization.
let authorizationService = try! container.resolve() as AuthorizationServiceProtocol
authorizationService.add(authorizationHandler: TaskOwnerAuthorizationHandler())