feat(oauth): default team for user on oauth settings

pull/2749/head
baron_l 2019-02-07 19:32:02 +01:00
parent 4d8133f696
commit 2755527d28
6 changed files with 37 additions and 7 deletions

View File

@ -67,6 +67,7 @@ type (
UserIdentifier string `json:"UserIdentifier"`
Scopes string `json:"Scopes"`
OAuthAutoCreateUsers bool `json:"OAuthAutoCreateUsers"`
DefaultTeamID TeamID `json:"DefaultTeamID"`
}
// TLSConfiguration represents a TLS configuration

View File

@ -149,6 +149,9 @@
</div>
</div>
<div class="col-sm-12 form-section-title">
Automatic user provisioning
</div>
<div class="form-group">
<span class="col-sm-12 text-muted small">
With automatic user provisioning enabled, Portainer will create user(s) automatically with standard user role. If
@ -163,4 +166,25 @@
</label>
</div>
</div>
<div ng-if="$ctrl.settings.OAuthAutoCreateUsers">
<div class="form-group">
<span class="col-sm-12 text-muted small">
The users created by the automatic provisioning feature can be added to a default team on creation. This setting is optional.
</span>
</div>
<div class="form-group">
<label for="team_provisioning" class="col-sm-2 col-lg-1">Default team</label>
<div class="col-sm-1">
<button type="button" class="btn btn-sm btn-danger pull-right" ng-click="$ctrl.settings.DefaultTeamID = null"
ng-disabled="!$ctrl.settings.DefaultTeamID">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
</div>
<div class="col-sm-9 col-lg-10">
<select class="form-control" ng-model="$ctrl.settings.DefaultTeamID" ng-options="team.Id as team.Name for team in $ctrl.teams">
</select>
</div>
</div>
</div>
</div>

View File

@ -1,6 +1,7 @@
angular.module('portainer.extensions.oauth').component('oauthSettings', {
templateUrl: 'app/extensions/oauth/components/oauth-settings/oauth-settings.html',
bindings: {
settings: '<'
settings: '<',
teams: '<'
}
});

View File

@ -53,4 +53,5 @@ function OAuthSettingsViewModel(data) {
this.UserIdentifier = data.UserIdentifier;
this.Scopes = data.Scopes;
this.OAuthAutoCreateUsers = data.OAuthAutoCreateUsers;
this.DefaultTeamID = data.DefaultTeamID;
}

View File

@ -322,7 +322,7 @@
<!-- !group-search-settings -->
</div>
<oauth-settings ng-if="isOauthEnabled()" settings="OAuthSettings"></oauth-settings>
<oauth-settings ng-if="isOauthEnabled()" settings="OAuthSettings" teams="teams"></oauth-settings>
<!-- actions -->
<div class="form-group">

View File

@ -1,6 +1,6 @@
angular.module('portainer.app')
.controller('SettingsAuthenticationController', ['$q', '$scope', 'Notifications', 'SettingsService', 'FileUploadService',
function ($q, $scope, Notifications, SettingsService, FileUploadService) {
.controller('SettingsAuthenticationController', ['$q', '$scope', 'Notifications', 'SettingsService', 'FileUploadService', 'TeamService',
function ($q, $scope, Notifications, SettingsService, FileUploadService, TeamService) {
$scope.state = {
successfulConnectivityCheck: false,
@ -96,9 +96,12 @@ function ($q, $scope, Notifications, SettingsService, FileUploadService) {
}
function initView() {
SettingsService.settings()
.then(function success(data) {
var settings = data;
$q.all({
settings: SettingsService.settings(),
teams: TeamService.teams()
}).then(function success(data) {
var settings = data.settings;
$scope.teams = data.teams;
$scope.settings = settings;
$scope.LDAPSettings = settings.LDAPSettings;
$scope.OAuthSettings = settings.OAuthSettings;