更新oauth2 introspection插件及docker自动编译脚本

This commit is contained in:
Liujian
2025-06-12 15:38:30 +08:00
parent 417bdff6d9
commit 6b7a2afd21
7 changed files with 31 additions and 17 deletions

View File

@@ -10,7 +10,12 @@ echo $0
VERSION=$(genVersion $1)
ARCH=$2
OUTPATH="${BasePath}/out/apinto-${VERSION}"
if [[ "$ARCH" == "" ]]
then
ARCH="amd64"
fi
OUTPATH="${BasePath}/out/apinto-${VERSION}-${ARCH}"
buildApp apinto $VERSION ${ARCH}
cp -a ${BasePath}/build/resources/* ${OUTPATH}/

View File

@@ -31,7 +31,12 @@ function genVersion(){
function buildApp(){
APP=$1
VERSION=$2
OUTPATH="${BasePath}/out/${APP}-${VERSION}"
ARCH=$3
if [[ "$ARCH" == "" ]]
then
ARCH="amd64"
fi
OUTPATH="${BasePath}/out/${APP}-${VERSION}-${ARCH}"
echo "rm -rf ${OUTPATH}"
rm -rf ${OUTPATH}
echo "mkdir -p ${OUTPATH}"
@@ -45,11 +50,7 @@ function buildApp(){
-X 'github.com/eolinker/apinto/utils/version.goVersion=$(go version)'
-X 'github.com/eolinker/apinto/utils/version.eoscVersion=${EOSC_VERSION}'"
echo -e "build $APP:go build -ldflags "-w -s $flags" -o ${OUTPATH}/$APP ${BasePath}/app/$APP"
ARCH=$3
if [[ "$ARCH" == "" ]]
then
ARCH="amd64"
fi
echo "CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags \"-w -s $flags\" -o ${OUTPATH}/$APP ${BasePath}/app/$APP"
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "-w -s $flags" -o ${OUTPATH}/$APP ${BasePath}/app/$APP
# echo "build $APP:${buildCMD}"
@@ -73,7 +74,8 @@ function packageApp(){
then
ARCH="amd64"
fi
cp -r "${BasePath}/out/${APP}-${VERSION}" "${BasePath}/out/${APP}"
OUTPATH="${BasePath}/out/${APP}-${VERSION}-${ARCH}"
cp -r "${OUTPATH}" "${BasePath}/out/${APP}"
cd "${BasePath}/out"
tar -zcf "${BasePath}/out/${APP}_${VERSION}_linux_${ARCH}.tar.gz" ${APP}
rm -rf "${BasePath}/out/${APP}"

View File

@@ -6,11 +6,16 @@ cd ${BasePath}/
VERSION=$(genVersion $1)
folder="${BasePath}/out/apinto-${VERSION}"
ARCH=$2
if [[ "$ARCH" == "" ]]
then
ARCH="amd64"
fi
folder="${BasePath}/out/apinto-${VERSION}-${ARCH}"
if [[ ! -d "$folder" ]]
then
# mkdir -p "$folder"
mkdir -p "$folder"
${CMD}/build.sh $1 ${ARCH}
if [[ "$?" != "0" ]]
then

View File

@@ -26,6 +26,9 @@ func check(v interface{}) (*Config, error) {
func getList(ids []eosc.RequireId) ([]output.IEntryOutput, error) {
ls := make([]output.IEntryOutput, 0, len(ids))
for _, id := range ids {
if workers == nil {
continue
}
worker, has := workers.Get(string(id))
if !has {
return nil, fmt.Errorf("%s:%w", id, eosc.ErrorWorkerNotExits)

View File

@@ -36,7 +36,6 @@ func check(v interface{}) (*Config, error) {
}
}
if len(strings.TrimSpace(conf.ResponseSchema)) > 0 {
var val interface{}

View File

@@ -128,7 +128,7 @@ func (e *executor) DoHttpFilter(ctx http_service.IHttpContext, next eocontext.IC
return fmt.Errorf(errInfo)
}
}
err = verifyIntrospection(introspectionInfo.Config, e.clientId, e.scopes)
err = verifyIntrospection(introspectionInfo.Config, e.scopes)
if err != nil {
// 校验失败
errInfo := fmt.Sprintf("verify introspection error: %s", err.Error())

View File

@@ -47,20 +47,20 @@ func setAppLabel(ctx http_service.IHttpContext, t *IntrospectionResponseBody, co
ctx.Proxy().Header().SetHeader("X-Consumer-Anonymous", "true")
}
ctx.SetLabel("application_id", a.Id())
ctx.SetLabel("application_name", a.Name())
ctx.SetLabel("application", a.Name())
ctx.Proxy().Header().SetHeader("X-Consumer-ID", a.Id())
ctx.Proxy().Header().SetHeader("X-Consumer-Username", a.Name())
return nil
}
func verifyIntrospection(t *IntrospectionResponseBody, clientId string, scopes map[string]struct{}) error {
func verifyIntrospection(t *IntrospectionResponseBody, scopes map[string]struct{}) error {
if t.Active != true {
return fmt.Errorf("token is not active")
}
if t.ClientId != clientId {
return fmt.Errorf("invalid client_id")
}
//if t.ClientId != clientId {
// return fmt.Errorf("invalid client_id")
//}
now := time.Now()
if t.Exp < now.Unix() {