mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 23:39:41 +02:00
feat(oauth): update OAuth UX
This commit is contained in:
parent
16226b1202
commit
de76ba4e67
10 changed files with 278 additions and 139 deletions
|
@ -1,11 +1,38 @@
|
|||
angular.module('portainer.extensions.oauth')
|
||||
.controller('OAuthSettingsController', function OAuthSettingsController() {
|
||||
this.onSelectProvider = onSelectProvider;
|
||||
.controller('OAuthSettingsController', function OAuthSettingsController() {
|
||||
var ctrl = this;
|
||||
|
||||
function onSelectProvider(provider) {
|
||||
this.settings.AuthorizationURI = provider.authUrl;
|
||||
this.settings.AccessTokenURI = provider.accessTokenUrl;
|
||||
this.settings.ResourceURI = provider.resourceUrl;
|
||||
this.settings.UserIdentifier = provider.userIdentifier;
|
||||
}
|
||||
});
|
||||
this.state = {
|
||||
provider: {},
|
||||
overrideConfiguration: false,
|
||||
microsoftTenantID: ''
|
||||
};
|
||||
|
||||
this.$onInit = onInit;
|
||||
this.onSelectProvider = onSelectProvider;
|
||||
this.onMicrosoftTenantIDChange = onMicrosoftTenantIDChange;
|
||||
|
||||
function onMicrosoftTenantIDChange() {
|
||||
var tenantID = ctrl.state.microsoftTenantID;
|
||||
|
||||
ctrl.settings.AuthorizationURI = _.replace('https://login.microsoftonline.com/TENANT_ID/oauth2/authorize', 'TENANT_ID', tenantID);
|
||||
ctrl.settings.AccessTokenURI = _.replace('https://login.microsoftonline.com/TENANT_ID/oauth2/token', 'TENANT_ID', tenantID);
|
||||
ctrl.settings.ResourceURI = _.replace('https://graph.windows.net/TENANT_ID/me?api-version=2013-11-08', 'TENANT_ID', tenantID);
|
||||
}
|
||||
|
||||
function onSelectProvider(provider) {
|
||||
ctrl.state.provider = provider;
|
||||
ctrl.settings.AuthorizationURI = provider.authUrl;
|
||||
ctrl.settings.AccessTokenURI = provider.accessTokenUrl;
|
||||
ctrl.settings.ResourceURI = provider.resourceUrl;
|
||||
ctrl.settings.UserIdentifier = provider.userIdentifier;
|
||||
ctrl.settings.Scopes = provider.scopes;
|
||||
}
|
||||
|
||||
function onInit() {
|
||||
if (ctrl.settings.RedirectURI === '') {
|
||||
ctrl.settings.RedirectURI = window.location.origin;
|
||||
}
|
||||
ctrl.state.provider.authUrl = ctrl.settings.AuthorizationURI;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue