style: unexpose BaseAuth (into baseAuth) since its package-private

This commit is contained in:
Guy Lewin 2020-02-24 16:00:11 -05:00
parent be8db5feb7
commit 0823d94fab
3 changed files with 16 additions and 16 deletions

View File

@ -20,7 +20,7 @@ import (
"github.com/fatedier/frp/models/msg"
)
type BaseAuth struct {
type baseAuth struct {
authenticateHeartBeats bool
authenticateNewWorkConns bool
}
@ -32,17 +32,17 @@ type Setter interface {
}
func NewAuthSetter(cfg config.ClientCommonConf) (authProvider Setter) {
baseAuth := BaseAuth{
base := baseAuth{
authenticateHeartBeats: cfg.AuthenticateHeartBeats,
authenticateNewWorkConns: cfg.AuthenticateNewWorkConns,
}
switch cfg.AuthenticationMethod {
case consts.TokenAuthMethod:
authProvider = NewTokenAuth(baseAuth, cfg.Token)
authProvider = NewTokenAuth(base, cfg.Token)
case consts.OidcAuthMethod:
authProvider = NewOidcAuthSetter(
baseAuth,
base,
cfg.OidcClientId,
cfg.OidcClientSecret,
cfg.OidcAudience,
@ -60,17 +60,17 @@ type Verifier interface {
}
func NewAuthVerifier(cfg config.ServerCommonConf) (authVerifier Verifier) {
baseAuth := BaseAuth{
base := baseAuth{
authenticateHeartBeats: cfg.AuthenticateHeartBeats,
authenticateNewWorkConns: cfg.AuthenticateNewWorkConns,
}
switch cfg.AuthenticationMethod {
case consts.TokenAuthMethod:
authVerifier = NewTokenAuth(baseAuth, cfg.Token)
authVerifier = NewTokenAuth(base, cfg.Token)
case consts.OidcAuthMethod:
authVerifier = NewOidcAuthVerifier(
baseAuth,
base,
cfg.OidcIssuer,
cfg.OidcAudience,
cfg.OidcSkipExpiryCheck,

View File

@ -25,12 +25,12 @@ import (
)
type OidcAuthProvider struct {
BaseAuth
baseAuth
tokenGenerator *clientcredentials.Config
}
func NewOidcAuthSetter(baseAuth BaseAuth, clientId string, clientSecret string, audience string, tokenEndpointUrl string) *OidcAuthProvider {
func NewOidcAuthSetter(base baseAuth, clientId string, clientSecret string, audience string, tokenEndpointUrl string) *OidcAuthProvider {
tokenGenerator := &clientcredentials.Config{
ClientID: clientId,
ClientSecret: clientSecret,
@ -39,7 +39,7 @@ func NewOidcAuthSetter(baseAuth BaseAuth, clientId string, clientSecret string,
}
return &OidcAuthProvider{
BaseAuth: baseAuth,
baseAuth: base,
tokenGenerator: tokenGenerator,
}
}
@ -76,13 +76,13 @@ func (auth *OidcAuthProvider) SetNewWorkConn(newWorkConnMsg *msg.NewWorkConn) (e
}
type OidcAuthConsumer struct {
BaseAuth
baseAuth
verifier *oidc.IDTokenVerifier
subjectFromLogin string
}
func NewOidcAuthVerifier(baseAuth BaseAuth, issuer string, audience string, skipExpiryCheck bool, skipIssuerCheck bool) *OidcAuthConsumer {
func NewOidcAuthVerifier(base baseAuth, issuer string, audience string, skipExpiryCheck bool, skipIssuerCheck bool) *OidcAuthConsumer {
provider, err := oidc.NewProvider(context.Background(), issuer)
if err != nil {
panic(err)
@ -94,7 +94,7 @@ func NewOidcAuthVerifier(baseAuth BaseAuth, issuer string, audience string, skip
SkipIssuerCheck: skipIssuerCheck,
}
return &OidcAuthConsumer{
BaseAuth: baseAuth,
baseAuth: base,
verifier: provider.Verifier(&verifierConf),
}
}

View File

@ -22,14 +22,14 @@ import (
)
type TokenAuthSetterVerifier struct {
BaseAuth
baseAuth
token string
}
func NewTokenAuth(baseAuth BaseAuth, token string) *TokenAuthSetterVerifier {
func NewTokenAuth(base baseAuth, token string) *TokenAuthSetterVerifier {
return &TokenAuthSetterVerifier{
BaseAuth: baseAuth,
baseAuth: base,
token: token,
}
}