mirror of https://github.com/portainer/portainer
feat(oauth): update authentication panel with OAuth provider details
parent
e325ad10dd
commit
9918c1260b
|
@ -29,7 +29,16 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-12" >
|
<div class="col-sm-12" >
|
||||||
<a ng-href="{{OAuthLoginURI}}" ng-if="AuthenticationMethod === 3">
|
<a ng-href="{{OAuthLoginURI}}" ng-if="AuthenticationMethod === 3">
|
||||||
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px">
|
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px" ng-if="state.OAuthProvider === 'Microsoft'">
|
||||||
|
<i class="fab fa-microsoft" aria-hidden="true"></i> Login with Microsoft
|
||||||
|
</div>
|
||||||
|
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px" ng-if="state.OAuthProvider === 'Google'">
|
||||||
|
<i class="fab fa-google" aria-hidden="true" ></i> Login with Google
|
||||||
|
</div>
|
||||||
|
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px" ng-if="state.OAuthProvider === 'Github'">
|
||||||
|
<i class="fab fa-github" aria-hidden="true" ></i> Login with Github
|
||||||
|
</div>
|
||||||
|
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px" ng-if="state.OAuthProvider === ''">
|
||||||
<i class="fa fa-sign-in-alt" aria-hidden="true" ></i> Login with OAuth
|
<i class="fa fa-sign-in-alt" aria-hidden="true" ></i> Login with OAuth
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
angular.module('portainer.app').controller('AuthenticationController', ['$q', '$scope', '$state', '$stateParams', '$sanitize', 'Authentication', 'UserService', 'EndpointService', 'StateManager', 'Notifications', 'SettingsService', 'URLHelper',
|
angular.module('portainer.app')
|
||||||
|
.controller('AuthenticationController', ['$q', '$scope', '$state', '$stateParams', '$sanitize', 'Authentication', 'UserService', 'EndpointService', 'StateManager', 'Notifications', 'SettingsService', 'URLHelper',
|
||||||
function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService, URLHelper) {
|
function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService, URLHelper) {
|
||||||
$scope.logo = StateManager.getState().application.logo;
|
$scope.logo = StateManager.getState().application.logo;
|
||||||
|
|
||||||
|
@ -9,7 +10,8 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
|
||||||
|
|
||||||
$scope.state = {
|
$scope.state = {
|
||||||
AuthenticationError: '',
|
AuthenticationError: '',
|
||||||
isInOAuthProcess: true
|
isInOAuthProcess: true,
|
||||||
|
OAuthProvider: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.authenticateUser = function() {
|
$scope.authenticateUser = function() {
|
||||||
|
@ -80,11 +82,25 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function determineOauthProvider(LoginURI) {
|
||||||
|
if (LoginURI.indexOf('login.microsoftonline.com') !== -1) {
|
||||||
|
return 'Microsoft';
|
||||||
|
}
|
||||||
|
else if (LoginURI.indexOf('accounts.google.com') !== -1) {
|
||||||
|
return 'Google';
|
||||||
|
}
|
||||||
|
else if (LoginURI.indexOf('github.com') !== -1) {
|
||||||
|
return 'Github';
|
||||||
|
}
|
||||||
|
return 'OAuth';
|
||||||
|
}
|
||||||
|
|
||||||
function initView() {
|
function initView() {
|
||||||
SettingsService.publicSettings()
|
SettingsService.publicSettings()
|
||||||
.then(function success(settings) {
|
.then(function success(settings) {
|
||||||
$scope.AuthenticationMethod = settings.AuthenticationMethod;
|
$scope.AuthenticationMethod = settings.AuthenticationMethod;
|
||||||
$scope.OAuthLoginURI = settings.OAuthLoginURI;
|
$scope.OAuthLoginURI = settings.OAuthLoginURI;
|
||||||
|
$scope.state.OAuthProvider = determineOauthProvider(settings.OAuthLoginURI);
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($stateParams.logout || $stateParams.error) {
|
if ($stateParams.logout || $stateParams.error) {
|
||||||
|
|
Loading…
Reference in New Issue