Skip to content

Instantly share code, notes, and snippets.

View ugurcemozturk's full-sized avatar
:shipit:
Stalking your pins

Ugur Cem Ozturk ugurcemozturk

:shipit:
Stalking your pins
View GitHub Profile
@ugurcemozturk
ugurcemozturk / signed-url-template.yml
Created August 17, 2020 15:59
Cloudformation template to create an API gateway that triggers a lambda to get a signed url of a S3 object from cloudfront
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: "Stack to create signed URLs through API Gateway"
Parameters:
ImagesBucket:
Type: String
Description: Bucket name of the images
UrlExpire:
Type: Number
Description: Expire of signed image url in miliseconds
@ugurcemozturk
ugurcemozturk / getImage.js
Created August 17, 2020 15:10
Create a signed Cloudfront URL for an object in S3 on AWS
const AWS = require("aws-sdk");
var fs = require('fs');
exports.GetImage = async(event) => {
try {
let image = event['pathParameters']['img']
let ImageKey = `${process.env.IMAGE_FOLDER}/${image}`;
const cloudfrontAccessKeyId = process.env.CLOUDFRONT_KEY_ID;
namespace dotnetJWT.Configuration
{
public static class JwtConfiguration
{
public static void ConfigureJwt(IServiceCollection services)
{
services.AddAuthentication(configureOptions =>
{
configureOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
configureOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
@ugurcemozturk
ugurcemozturk / yml
Created January 10, 2019 19:37
contorderainer.yml
version: "3"
services:
A servisi:
image: güzel_imaj
ports:
- lokalPort:containerPort
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:15672"]
/*
Süpriz sonlu, konulu contract
*/
pragma solidity ^0.4.19;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
contract HappyEnding is usingOraclize {
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) public pure returns (uint c) {
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
private DeveloperRepository developerRepository;
public UserDetailsServiceImpl(DeveloperRepository developerRepository) {
this.developerRepository = developerRepository;
}
@Override
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private UserDetailsService userDetailsService;
@Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;
public WebSecurityConfig(UserDetailsService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
this.userDetailsService = userDetailsService;
this.bCryptPasswordEncoder = bCryptPasswordEncoder;
public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
private AuthenticationManager authenticationManager;
public JWTAuthenticationFilter(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
@Override
public class SecurityConstants {
public static final String SECRET = "Emakina";
public static final long EXPIRATION_TIME = 423_000_000; // 5 gün
public static final String TOKEN_PREFIX = "Bearer ";
public static final String HEADER_STRING = "Authorization";
public static final String SIGN_UP_URL = "/developers/sign-up";
}