Compare commits

..

3 Commits
dev ... master

Author SHA1 Message Date
lab
d7016ad386 Merge branch 'dev' 2021-11-10 03:03:34 +08:00
lab
661c189bf4 Merge branch 'dev' 2021-11-10 02:33:52 +08:00
lab
64b33915da Merge branch 'dev' 2021-11-10 01:49:51 +08:00
4 changed files with 1 additions and 53 deletions

View File

@ -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"]

View File

@ -1,7 +1,7 @@
include .env
include .env.local
.PHONY: build proto
.PHONY: proto
run:
go run cmd/mp-server/main.go \
@ -15,13 +15,6 @@ clean:
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 esinio/weixin:oauth2

View File

@ -7,7 +7,6 @@ import (
pb "git.esin.io/lab/weixin/protobuf/clientapi/mp/auth"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"
)
var (
@ -44,7 +43,6 @@ func run() error {
http.HandleFunc("/token", h.exchangeToken)
http.HandleFunc("/userinfo", h.getUserinfo)
http.HandleFunc("/userinfo/sync", h.syncUserinfo)
http.HandleFunc("/clientcredential", h.getClientCredential)
return http.ListenAndServe(":"+lisPort, nil)
}
@ -113,12 +111,3 @@ func (h restHandler) syncUserinfo(w http.ResponseWriter, r *http.Request) {
}
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
View File

@ -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
)