Skip to content

Instantly share code, notes, and snippets.

View strongant's full-sized avatar

strongant strongant

View GitHub Profile
@strongant
strongant / consul-node-service-address-unique.sh
Created December 1, 2022 11:36
consul node service 获取某个服务分布在哪些consul node上。
curl https://localhost:8500/v1/health/service/[servicename]\?passing\=true | jq '{serviceAddress:.[].Service.Address , nodeAddress:.[].Node.Address}' | sort | uniq
@strongant
strongant / auto-install-consul-start-service.sh
Last active December 1, 2022 06:29
自动安装consul,并创建对应的service并运行consul服务
echo '
#! /bin/bash
####### yum update is optional #####
#yum -y update
sudo yum install firewalld -y
sudo systemctl start firewalld
sudo firewall-cmd --add-port=8300/tcp --add-port=8301/tcp --add-port=8302/tcp --add-port=8400/tcp --add-port=8500/tcp --add-port=80/tcp --add-port=443/tcp --permanent
sudo firewall-cmd --reload
sudo yum -y install unzip wget
@strongant
strongant / gist:160d7a5a226cb1e0be5c9ec1cb212402
Created November 23, 2022 10:58 — forked from programaker/gist:5867408
Sending post request with params and fetching response content
public static String post(String urlString, String params, int timeout) throws Exception {
String response = null;
HttpURLConnection conn = null;
DataOutputStream dos = null;
InputStream is = null;
try {
URL url = new URL(urlString);
conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
@strongant
strongant / default-user.yaml
Created November 17, 2022 12:35
默认的k8s用户权限,仅限测试环境使用
kubectl create clusterrolebinding system:anonymous --clusterrole=cluster-admin --user=system:anonymous
@strongant
strongant / kubectl-delete-all.sh
Created October 28, 2022 15:14
kubectl delete all resources
kubectl delete all --all --all-namespaces
@strongant
strongant / get-consul-service-instance.py
Created October 27, 2022 02:56
get-consul-service-instance.py
# coding=utf-8
import json
import urllib
from urllib.request import urlopen
from urllib import request
# from urllib2 import urlopen
import sys
@strongant
strongant / ab-get-header.sh
Created September 28, 2022 17:31
ab add header to get requests
ab -n 10000 -c 100 -H "Authorization:Bearersdfsdds123" -H "AuthClientId:atas" -v 1 $podip:8080/test/111
@strongant
strongant / consul info.txt
Last active September 20, 2022 12:50
sh consul info
#consul info
agent:
check_monitors = 0
check_ttls = 0
checks = 0
services = 0
build:
prerelease =
revision = 944e8ce6
version = 1.11.4

This gist describes the configuration required for Spring reactive WebClient to make a call to an OAuth2 protected resource through OAuth2.0 Client Credentials Grant Type Flow.

Assumption is that the Authorization Server supports OpenId Connect 1.0 specifications.

@strongant
strongant / FeignConfiguration.java
Created September 2, 2022 17:33 — forked from mehmetcemyucel/FeignConfiguration.java
keycloak-feign-resttemplate
package com.cem.oauth2.configuration.feign;
import com.cem.oauth2.configuration.AuthProperties;
import feign.RequestInterceptor;
import org.keycloak.OAuth2Constants;
import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;