Compare commits
	
		
			3 Commits
		
	
	
		
			dev
			...
			d7016ad386
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d7016ad386 | |||
| 661c189bf4 | |||
| 64b33915da | 
							
								
								
									
										15
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -1,15 +0,0 @@
 | 
				
			|||||||
FROM alpine as build
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ADD ./build/app /app
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
 | 
					 | 
				
			||||||
    && apk --no-cache add ca-certificates
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
FROM scratch
 | 
					 | 
				
			||||||
# copy the ca-certificate.crt from the build stage
 | 
					 | 
				
			||||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
 | 
					 | 
				
			||||||
COPY --from=build /app /app
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EXPOSE 13721
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ENTRYPOINT ["/app"]
 | 
					 | 
				
			||||||
							
								
								
									
										9
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
				
			|||||||
include .env
 | 
					include .env
 | 
				
			||||||
include .env.local
 | 
					include .env.local
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.PHONY: build proto 
 | 
					.PHONY: proto 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
run:
 | 
					run:
 | 
				
			||||||
	go run cmd/mp-server/main.go \
 | 
						go run cmd/mp-server/main.go \
 | 
				
			||||||
@@ -15,13 +15,6 @@ clean:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
all: api
 | 
					all: api
 | 
				
			||||||
 | 
					
 | 
				
			||||||
build:
 | 
					 | 
				
			||||||
	CGO_ENABLED=0 GOOS="linux" GOARCH="amd64" \
 | 
					 | 
				
			||||||
		go build -o ./build/app -ldflags="-s -w" -tags timetzdata  ./cmd/mp-server
 | 
					 | 
				
			||||||
	upx build/app
 | 
					 | 
				
			||||||
	docker build -t esinio/weixin:mp-auth .
 | 
					 | 
				
			||||||
	rm build/app
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
docker.push:
 | 
					docker.push:
 | 
				
			||||||
	docker push esinio/weixin:oauth2
 | 
						docker push esinio/weixin:oauth2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,6 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	pb "git.esin.io/lab/weixin/protobuf/clientapi/mp/auth"
 | 
						pb "git.esin.io/lab/weixin/protobuf/clientapi/mp/auth"
 | 
				
			||||||
	"google.golang.org/grpc"
 | 
						"google.golang.org/grpc"
 | 
				
			||||||
	"google.golang.org/protobuf/types/known/emptypb"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
@@ -44,7 +43,6 @@ func run() error {
 | 
				
			|||||||
	http.HandleFunc("/token", h.exchangeToken)
 | 
						http.HandleFunc("/token", h.exchangeToken)
 | 
				
			||||||
	http.HandleFunc("/userinfo", h.getUserinfo)
 | 
						http.HandleFunc("/userinfo", h.getUserinfo)
 | 
				
			||||||
	http.HandleFunc("/userinfo/sync", h.syncUserinfo)
 | 
						http.HandleFunc("/userinfo/sync", h.syncUserinfo)
 | 
				
			||||||
	http.HandleFunc("/clientcredential", h.getClientCredential)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return http.ListenAndServe(":"+lisPort, nil)
 | 
						return http.ListenAndServe(":"+lisPort, nil)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -113,12 +111,3 @@ func (h restHandler) syncUserinfo(w http.ResponseWriter, r *http.Request) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	json.NewEncoder(w).Encode(resp)
 | 
						json.NewEncoder(w).Encode(resp)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func (h restHandler) getClientCredential(w http.ResponseWriter, r *http.Request) {
 | 
					 | 
				
			||||||
	resp, err := h.client.GetClientCredential(r.Context(), &emptypb.Empty{})
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	json.NewEncoder(w).Encode(resp)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								db.sql
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								db.sql
									
									
									
									
									
								
							@@ -1,19 +0,0 @@
 | 
				
			|||||||
create schema  "identity"
 | 
					 | 
				
			||||||
    create table if not exists "user" (
 | 
					 | 
				
			||||||
        id text primary key,
 | 
					 | 
				
			||||||
        openid text unique not null,
 | 
					 | 
				
			||||||
        created_at timestamp with time zone default current_timestamp,
 | 
					 | 
				
			||||||
        updated_at timestamp with time zone default current_timestamp
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
    create table if not exists "user_token" (
 | 
					 | 
				
			||||||
        user_id text primary key,
 | 
					 | 
				
			||||||
        access_token text,
 | 
					 | 
				
			||||||
        expires_in smallint,
 | 
					 | 
				
			||||||
        refresh_token text,
 | 
					 | 
				
			||||||
        scope text
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
    create table if not exists "user_userinfo" (
 | 
					 | 
				
			||||||
        user_id text primary key,
 | 
					 | 
				
			||||||
        nickname text,
 | 
					 | 
				
			||||||
        head_img_url text
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user