mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #23240 from zhouhaibing089/keystone_fix
Auto commit by PR queue bot
This commit is contained in:
commit
4bfd42bbc2
@ -23,9 +23,9 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/auth/authenticator/bearertoken"
|
"k8s.io/kubernetes/pkg/auth/authenticator/bearertoken"
|
||||||
"k8s.io/kubernetes/pkg/serviceaccount"
|
"k8s.io/kubernetes/pkg/serviceaccount"
|
||||||
"k8s.io/kubernetes/pkg/util/crypto"
|
"k8s.io/kubernetes/pkg/util/crypto"
|
||||||
|
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/password/keystone"
|
||||||
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/password/passwordfile"
|
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/password/passwordfile"
|
||||||
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/basicauth"
|
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/basicauth"
|
||||||
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/keystone"
|
|
||||||
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/union"
|
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/union"
|
||||||
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/x509"
|
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/request/x509"
|
||||||
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/token/oidc"
|
"k8s.io/kubernetes/plugin/pkg/auth/authenticator/token/oidc"
|
||||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Package keystone provide authentication via keystone.
|
// Package keystone provides authentication via keystone.
|
||||||
// For details //about keystone and how to use the plugin, refer to
|
// For details about keystone and how to use the plugin, refer to
|
||||||
// https://github.com/kubernetes/kubernetes/blob/oidc/docs/admin/authentication.md
|
// https://github.com/kubernetes/kubernetes.github.io/blob/master/docs/admin/authentication.md
|
||||||
package keystone
|
package keystone
|
@ -26,12 +26,13 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/auth/user"
|
"k8s.io/kubernetes/pkg/auth/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Keystone authenticator contacts openstack keystone to validate user's credentials passed in the request.
|
// KeystoneAuthenticator contacts openstack keystone to validate user's credentials passed in the request.
|
||||||
// The keystone endpoint is passed during apiserver startup
|
// The keystone endpoint is passed during apiserver startup
|
||||||
type KeystoneAuthenticator struct {
|
type KeystoneAuthenticator struct {
|
||||||
authURL string
|
authURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AuthenticatePassword checks the username, password via keystone call
|
||||||
func (keystoneAuthenticator *KeystoneAuthenticator) AuthenticatePassword(username string, password string) (user.Info, bool, error) {
|
func (keystoneAuthenticator *KeystoneAuthenticator) AuthenticatePassword(username string, password string) (user.Info, bool, error) {
|
||||||
opts := gophercloud.AuthOptions{
|
opts := gophercloud.AuthOptions{
|
||||||
IdentityEndpoint: keystoneAuthenticator.authURL,
|
IdentityEndpoint: keystoneAuthenticator.authURL,
|
||||||
@ -48,7 +49,7 @@ func (keystoneAuthenticator *KeystoneAuthenticator) AuthenticatePassword(usernam
|
|||||||
return &user.DefaultInfo{Name: username}, true, nil
|
return &user.DefaultInfo{Name: username}, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a request authenticator that validates credentials using openstack keystone
|
// NewKeystoneAuthenticator returns a password authenticator that validates credentials using openstack keystone
|
||||||
func NewKeystoneAuthenticator(authURL string) (*KeystoneAuthenticator, error) {
|
func NewKeystoneAuthenticator(authURL string) (*KeystoneAuthenticator, error) {
|
||||||
if !strings.HasPrefix(authURL, "https") {
|
if !strings.HasPrefix(authURL, "https") {
|
||||||
return nil, errors.New("Auth URL should be secure and start with https")
|
return nil, errors.New("Auth URL should be secure and start with https")
|
Loading…
Reference in New Issue
Block a user