Parcourir la source

Apply default Realm on Login

Daniel Potapov il y a 8 ans
Parent
commit
073e04ca4a
1 fichiers modifiés avec 3 ajouts et 5 suppressions
  1. 3 5
      client/client.go

+ 3 - 5
client/client.go

@@ -117,11 +117,6 @@ func NewClientFromCCache(c credentials.CCache) (Client, error) {
 // WithConfig sets the Kerberos configuration for the client.
 func (cl *Client) WithConfig(cfg *config.Config) *Client {
 	cl.Config = cfg
-
-	// Use the default Realm if user did not specified it when creating a client
-	if cl.Credentials.Realm == "" {
-		cl.Credentials.Realm = cl.Config.LibDefaults.DefaultRealm
-	}
 	return cl
 }
 
@@ -199,5 +194,8 @@ func (cl *Client) IsConfigured() (bool, error) {
 
 // Login the client with the KDC via an AS exchange.
 func (cl *Client) Login() error {
+	if cl.Credentials.Realm == "" {
+		cl.Credentials.Realm = cl.Config.LibDefaults.DefaultRealm
+	}
 	return cl.ASExchange(cl.Credentials.Realm, 0)
 }