Merge pull request #1541 from coreos-inc/external-auth-creds
Change the encrypted password dialog to use the user's external usern…
This commit is contained in:
commit
a793fd734c
3 changed files with 33 additions and 6 deletions
|
@ -83,6 +83,10 @@ angular.module('quay').directive('credentialsDialog', function () {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (credentials.namespace) {
|
||||||
|
return credentials.namespace;
|
||||||
|
}
|
||||||
|
|
||||||
return credentials.username.split('+')[0];
|
return credentials.username.split('+')[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,8 +170,7 @@ angular.module('quay').directive('credentialsDialog', function () {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
var username = credentials.username.replace('+', '-');
|
return $scope.getEscapedUsername(credentials) + '-pull-secret';
|
||||||
return username + '-pull-secret';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getKubernetesFile = function(credentials) {
|
$scope.getKubernetesFile = function(credentials) {
|
||||||
|
@ -190,13 +193,16 @@ angular.module('quay').directive('credentialsDialog', function () {
|
||||||
return $scope.getSuffixedFilename(credentials, 'secret.yml')
|
return $scope.getSuffixedFilename(credentials, 'secret.yml')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.getEscapedUsername = function(credentials) {
|
||||||
|
return credentials.username.replace(/[^a-zA-Z0-9]/, '-');
|
||||||
|
};
|
||||||
|
|
||||||
$scope.getSuffixedFilename = function(credentials, suffix) {
|
$scope.getSuffixedFilename = function(credentials, suffix) {
|
||||||
if (!credentials || !credentials.username) {
|
if (!credentials || !credentials.username) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
var username = credentials.username.replace('+', '-');
|
return $scope.getEscapedUsername(credentials) + '-' + suffix;
|
||||||
return username + '-' + suffix;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,14 +87,19 @@
|
||||||
|
|
||||||
$scope.generateClientToken = function() {
|
$scope.generateClientToken = function() {
|
||||||
var generateToken = function(password) {
|
var generateToken = function(password) {
|
||||||
|
if (!password) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
'password': password
|
'password': password
|
||||||
};
|
};
|
||||||
|
|
||||||
ApiService.generateUserClientKey(data).then(function(resp) {
|
ApiService.generateUserClientKey(data).then(function(resp) {
|
||||||
$scope.context.encryptedPasswordCredentials = {
|
$scope.context.encryptedPasswordCredentials = {
|
||||||
'username': $scope.context.viewuser.username,
|
'username': UserService.getCLIUsername(),
|
||||||
'password': resp['key']
|
'password': resp['key'],
|
||||||
|
'namespace': UserService.currentUser().username
|
||||||
};
|
};
|
||||||
}, ApiService.errorDisplay('Could not generate token'));
|
}, ApiService.errorDisplay('Could not generate token'));
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,7 @@ function(ApiService, CookieService, $rootScope, Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var userService = {}
|
var userService = {}
|
||||||
|
var _EXTERNAL_SERVICES = ['ldap', 'jwtauthn', 'keystone', 'dex'];
|
||||||
|
|
||||||
userService.hasEverLoggedIn = function() {
|
userService.hasEverLoggedIn = function() {
|
||||||
return CookieService.get('quay.loggedin') == 'true';
|
return CookieService.get('quay.loggedin') == 'true';
|
||||||
|
@ -147,6 +148,21 @@ function(ApiService, CookieService, $rootScope, Config) {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
userService.getCLIUsername = function() {
|
||||||
|
if (!userResponse) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var externalUsername = null;
|
||||||
|
userResponse.logins.forEach(function(login) {
|
||||||
|
if (_EXTERNAL_SERVICES.indexOf(login.service) >= 0) {
|
||||||
|
externalUsername = login.service_identifier;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return externalUsername || userResponse.username;
|
||||||
|
};
|
||||||
|
|
||||||
userService.currentUser = function() {
|
userService.currentUser = function() {
|
||||||
return userResponse;
|
return userResponse;
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue