Skip to content

Commit d3edd1f

Browse files
committed
ip
1 parent 429e69b commit d3edd1f

4 files changed

Lines changed: 6 additions & 9 deletions

File tree

handlers/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func CallbackHandler(w http.ResponseWriter, r *http.Request) {
5353
// - validate info from oauth provider (Google, GitHub, OIDC, etc)
5454
// - issue jwt in the form of a cookie
5555
func AuthStateHandler(w http.ResponseWriter, r *http.Request) {
56-
log.Debug("/auth/{state}/ api")
56+
log.Debug("/auth/{state}/")
5757
// Handle the exchange code to initiate a transport.
5858

5959
session, err := sessstore.Get(r, cfg.Cfg.Session.Name)

pkg/jwtmanager/jwtcache.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func JWTCacheHandler(next http.Handler) http.Handler {
5454
// check to see if the request is from a whitelisted IP
5555
ipWhitelist := cfg.Cfg.IPWhiteList
5656
ipHost, _, _ := net.SplitHostPort(r.RemoteAddr) // 去掉端口
57+
log.Debugf("request ip: %s", ipHost)
5758
for _, wip := range ipWhitelist {
5859
if ipHost == wip {
5960
logger.Debug("IP whitelisted, access granted")

pkg/providers/common/common.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ func PrepareTokensAndClient(r *http.Request, ptokens *structs.PTokens, setProvid
3535
sslClient := ClientWithCert(&http.Client{})
3636
ctx := context.WithValue(context.TODO(), oauth2.HTTPClient, sslClient)
3737
providerToken, err := cfg.OAuthClient.Exchange(ctx, r.URL.Query().Get("code"), opts...)
38-
log.Debugf("----->PrepareTokensAndClient 1")
3938
if err != nil {
4039
return nil, nil, err
4140
}
42-
log.Debugf("----->PrepareTokensAndClient 2")
4341
ptokens.PAccessToken = providerToken.AccessToken
4442

4543
if setProviderToken {
@@ -59,17 +57,17 @@ func PrepareTokensAndClient(r *http.Request, ptokens *structs.PTokens, setProvid
5957
}
6058

6159
func ClientWithCert(client *http.Client) *http.Client {
62-
log.Debugf("----->ClientWithCert 1")
60+
log.Debugf("ClientWithCert")
6361
certFile := cfg.Cfg.TLS.ClientCertFile
6462
keyFile := cfg.Cfg.TLS.ClientKeyFile
6563
if certFile == "" || keyFile == "" {
66-
log.Debugf("----->client ssl is null")
64+
log.Debugf("client ssl is null")
6765
return client
6866
}
6967
// 加载客户端证书
7068
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
7169
if err != nil {
72-
log.Debugf("----->client ssl load error: %v", err)
70+
log.Debugf("client ssl load error: %v", err)
7371
return client
7472
}
7573

@@ -95,7 +93,7 @@ func ClientWithCert(client *http.Client) *http.Client {
9593
TLSClientConfig: tlsConfig,
9694
}
9795
}
98-
log.Debugf("----->with client ssl success")
96+
log.Debugf("ClientWithCert success")
9997
return client
10098
}
10199

pkg/providers/openid/openid.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ func (Provider) Configure() {
3535

3636
// GetUserInfo provider specific call to get userinfomation
3737
func (Provider) GetUserInfo(r *http.Request, user *structs.User, customClaims *structs.CustomClaims, ptokens *structs.PTokens, opts ...oauth2.AuthCodeOption) (rerr error) {
38-
log.Debugf("----->client ssl get userinfo ")
3938
client, _, err := common.PrepareTokensAndClient(r, ptokens, true, opts...)
4039
if err != nil {
4140
return err
4241
}
4342
userinfo, err := client.Get(cfg.GenOAuth.UserInfoURL)
4443
if err != nil {
45-
log.Debugf("----->cclient ssl userinfo error: %v", err)
4644
return err
4745
}
4846
defer func() {

0 commit comments

Comments
 (0)