Skip to content

Instantly share code, notes, and snippets.

View sedkis's full-sized avatar
🌴
Working Remotely

Sedky Haider sedkis

🌴
Working Remotely
View GitHub Profile
FROM openjdk:8-jdk
RUN mkdir -p /usr/app
WORKDIR /usr/app
COPY ./target/my-jar.jar .
EXPOSE 8181
CMD /usr/bin/java -jar \
version: '3.7'
services:
my-java-service:
image: 'my-java-service:latest'
secrets:
- source: my-secret-DEV
target: my-secret
environment:
- SPRING_PROFILES_ACTIVE=dev
version: '3.7'
services:
my-java-service:
image: 'my-java-service:latest'
secrets:
- source: my-secret-prd
target: my-secret
environment:
- SPRING_PROFILES_ACTIVE=prd
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private String apiUser;
private String apiPassword;
@Autowired
public WebSecurityConfig(
@Value("${web.security.api.user}") String apiUser, // stored in plain text in application.properties
@sedkis
sedkis / virtualendpoint.js
Last active May 28, 2019 16:49
Virtual Endpoint HTTP Request (Timezone API)
// Makes API call to worldtimezone/api/timezone, and gets the time of the
// first 3 timezones and pretty formats it
function myVirtualHandler (request, session, config) {
//Make api call to upstream target
newRequest = {
"Method": "GET",
"Domain": "http://worldtimeapi.org",
"resource": "/api/timezone"
};
@sedkis
sedkis / virtualendpoint_createsession.js
Created July 14, 2019 23:48
Virtual Endpoint to Create Token through Dashboard
function myVirtualHandler(request, session, config) {
//Make api call to upstream target
newRequest = {
"Headers": {"Authorization":"103cbe6f3c9443575cc52451cd051ecb"},
"Method": "POST",
"Body":keyrequest,
"Domain": "http://www.tyk-test.com:3000",
"resource": "/api/keys",
};
@sedkis
sedkis / preTransformContentType.js
Last active September 18, 2019 14:42
Create Key Using Gateway
var preTransformContentType = new TykJS.TykMiddleware.NewMiddleware({});
preTransformContentType.NewProcessRequest(function(request, session, config) {
log("Running sample PRE PROCESSOR preTransformContentType middleware");
var thisSession = JSON.parse(TykGetKeyData(request.Headers["Authorization"], config.APIID))
if (thisSession.status == "error" || thisSession.expires >= 1 && thisSession.expires < Math.round((new Date()).getTime() / 1000)) {
log("Key expired, redirecting to login")
request.ReturnOverrides.ResponseCode = 301
// If you have a 50% chance of winning combined with a 40% chance of winning
// It is the same as having a 90% chance of winning combined with a 0 percent chance of winning
percentOfWin = 0.5;
percentOfWinTwo = 0.4;
totalWins = 0;
n = 100000;
while (n > 0) {
// First Draw
{
"name": "Tyk Cache API",
"api_id": "2",
"org_id": "default",
"auth": {},
"use_keyless": true,
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
@sedkis
sedkis / final
Last active March 31, 2020 19:44
tyk.standalone.conf with elasticache
{
"listen_port": 8080,
"secret": "352d20ee67be67f6340b4c0605b044b7",
"template_path": "/opt/tyk-gateway/templates",
"tyk_js_path": "/opt/tyk-gateway/js/tyk.js",
"middleware_path": "/opt/tyk-gateway/middleware",
"use_db_app_configs": false,
"app_path": "/opt/tyk-gateway/apps/",
"storage": {
"type": "redis",