mirror of
https://github.com/portainer/portainer.git
synced 2025-08-01 20:05:23 +02:00
feat(extensions): remove oauth extension (#4156)
* feat(oauth): remove oauth providers * feat(extensions): remove references to oauth extension
This commit is contained in:
parent
00f4fe0039
commit
ff250a202a
6 changed files with 15 additions and 138 deletions
|
@ -26,9 +26,8 @@ var extensionDownloadBaseURL = portainer.AssetsServerURL + "/extensions/"
|
||||||
var extensionVersionRegexp = regexp.MustCompile(`\d+(\.\d+)+`)
|
var extensionVersionRegexp = regexp.MustCompile(`\d+(\.\d+)+`)
|
||||||
|
|
||||||
var extensionBinaryMap = map[portainer.ExtensionID]string{
|
var extensionBinaryMap = map[portainer.ExtensionID]string{
|
||||||
portainer.RegistryManagementExtension: "extension-registry-management",
|
portainer.RegistryManagementExtension: "extension-registry-management",
|
||||||
portainer.OAuthAuthenticationExtension: "extension-oauth-authentication",
|
portainer.RBACExtension: "extension-rbac",
|
||||||
portainer.RBACExtension: "extension-rbac",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExtensionManager represents a service used to
|
// ExtensionManager represents a service used to
|
||||||
|
@ -114,8 +113,6 @@ func (manager *ExtensionManager) InstallExtension(extension *portainer.Extension
|
||||||
switch extension.ID {
|
switch extension.ID {
|
||||||
case portainer.RegistryManagementExtension:
|
case portainer.RegistryManagementExtension:
|
||||||
extension.Name = "Registry Manager"
|
extension.Name = "Registry Manager"
|
||||||
case portainer.OAuthAuthenticationExtension:
|
|
||||||
extension.Name = "External Authentication"
|
|
||||||
case portainer.RBACExtension:
|
case portainer.RBACExtension:
|
||||||
extension.Name = "Role-Based Access Control"
|
extension.Name = "Role-Based Access Control"
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,8 @@ import (
|
||||||
const azureAPIBaseURL = "https://management.azure.com"
|
const azureAPIBaseURL = "https://management.azure.com"
|
||||||
|
|
||||||
var extensionPorts = map[portainer.ExtensionID]string{
|
var extensionPorts = map[portainer.ExtensionID]string{
|
||||||
portainer.RegistryManagementExtension: "7001",
|
portainer.RegistryManagementExtension: "7001",
|
||||||
portainer.OAuthAuthenticationExtension: "7002",
|
portainer.RBACExtension: "7003",
|
||||||
portainer.RBACExtension: "7003",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
|
@ -1257,7 +1257,7 @@ const (
|
||||||
_ ExtensionID = iota
|
_ ExtensionID = iota
|
||||||
// RegistryManagementExtension represents the registry management extension
|
// RegistryManagementExtension represents the registry management extension
|
||||||
RegistryManagementExtension
|
RegistryManagementExtension
|
||||||
// OAuthAuthenticationExtension represents the OAuth authentication extension
|
// OAuthAuthenticationExtension represents the OAuth authentication extension (Deprecated)
|
||||||
OAuthAuthenticationExtension
|
OAuthAuthenticationExtension
|
||||||
// RBACExtension represents the RBAC extension
|
// RBACExtension represents the RBAC extension
|
||||||
RBACExtension
|
RBACExtension
|
||||||
|
|
|
@ -2,39 +2,6 @@ angular.module('portainer.oauth').controller('OAuthProviderSelectorController',
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
this.providers = [
|
this.providers = [
|
||||||
{
|
|
||||||
authUrl: 'https://login.microsoftonline.com/TENANT_ID/oauth2/authorize',
|
|
||||||
accessTokenUrl: 'https://login.microsoftonline.com/TENANT_ID/oauth2/token',
|
|
||||||
resourceUrl: 'https://graph.windows.net/TENANT_ID/me?api-version=2013-11-08',
|
|
||||||
userIdentifier: 'userPrincipalName',
|
|
||||||
scopes: 'id,email,name',
|
|
||||||
name: 'microsoft',
|
|
||||||
label: 'Microsoft',
|
|
||||||
description: 'Microsoft OAuth provider',
|
|
||||||
icon: 'fab fa-microsoft',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
authUrl: 'https://accounts.google.com/o/oauth2/auth',
|
|
||||||
accessTokenUrl: 'https://accounts.google.com/o/oauth2/token',
|
|
||||||
resourceUrl: 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json',
|
|
||||||
userIdentifier: 'email',
|
|
||||||
scopes: 'profile email',
|
|
||||||
name: 'google',
|
|
||||||
label: 'Google',
|
|
||||||
description: 'Google OAuth provider',
|
|
||||||
icon: 'fab fa-google',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
authUrl: 'https://github.com/login/oauth/authorize',
|
|
||||||
accessTokenUrl: 'https://github.com/login/oauth/access_token',
|
|
||||||
resourceUrl: 'https://api.github.com/user',
|
|
||||||
userIdentifier: 'login',
|
|
||||||
scopes: 'id email name',
|
|
||||||
name: 'github',
|
|
||||||
label: 'Github',
|
|
||||||
description: 'Github OAuth provider',
|
|
||||||
icon: 'fab fa-github',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
authUrl: '',
|
authUrl: '',
|
||||||
accessTokenUrl: '',
|
accessTokenUrl: '',
|
||||||
|
|
|
@ -1,75 +1,19 @@
|
||||||
import _ from 'lodash-es';
|
|
||||||
|
|
||||||
angular.module('portainer.oauth').controller('OAuthSettingsController', function OAuthSettingsController() {
|
angular.module('portainer.oauth').controller('OAuthSettingsController', function OAuthSettingsController() {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
provider: {},
|
provider: {},
|
||||||
overrideConfiguration: false,
|
|
||||||
microsoftTenantID: '',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$onInit = onInit;
|
this.$onInit = $onInit;
|
||||||
this.onSelectProvider = onSelectProvider;
|
|
||||||
this.onMicrosoftTenantIDChange = onMicrosoftTenantIDChange;
|
|
||||||
this.useDefaultProviderConfiguration = useDefaultProviderConfiguration;
|
|
||||||
|
|
||||||
function onMicrosoftTenantIDChange() {
|
function $onInit() {
|
||||||
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 useDefaultProviderConfiguration() {
|
|
||||||
ctrl.settings.AuthorizationURI = ctrl.state.provider.authUrl;
|
|
||||||
ctrl.settings.AccessTokenURI = ctrl.state.provider.accessTokenUrl;
|
|
||||||
ctrl.settings.ResourceURI = ctrl.state.provider.resourceUrl;
|
|
||||||
ctrl.settings.UserIdentifier = ctrl.state.provider.userIdentifier;
|
|
||||||
ctrl.settings.Scopes = ctrl.state.provider.scopes;
|
|
||||||
|
|
||||||
if (ctrl.state.provider.name === 'microsoft' && ctrl.state.microsoftTenantID !== '') {
|
|
||||||
onMicrosoftTenantIDChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function useExistingConfiguration() {
|
|
||||||
var provider = ctrl.state.provider;
|
|
||||||
ctrl.settings.AuthorizationURI = ctrl.settings.AuthorizationURI === '' ? provider.authUrl : ctrl.settings.AuthorizationURI;
|
|
||||||
ctrl.settings.AccessTokenURI = ctrl.settings.AccessTokenURI === '' ? provider.accessTokenUrl : ctrl.settings.AccessTokenURI;
|
|
||||||
ctrl.settings.ResourceURI = ctrl.settings.ResourceURI === '' ? provider.resourceUrl : ctrl.settings.ResourceURI;
|
|
||||||
ctrl.settings.UserIdentifier = ctrl.settings.UserIdentifier === '' ? provider.userIdentifier : ctrl.settings.UserIdentifier;
|
|
||||||
ctrl.settings.Scopes = ctrl.settings.Scopes === '' ? provider.scopes : ctrl.settings.Scopes;
|
|
||||||
|
|
||||||
if (provider.name === 'microsoft' && ctrl.state.microsoftTenantID !== '') {
|
|
||||||
onMicrosoftTenantIDChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSelectProvider(provider, overrideConfiguration) {
|
|
||||||
ctrl.state.provider = provider;
|
|
||||||
|
|
||||||
if (overrideConfiguration) {
|
|
||||||
useDefaultProviderConfiguration();
|
|
||||||
} else {
|
|
||||||
useExistingConfiguration();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onInit() {
|
|
||||||
if (ctrl.settings.RedirectURI === '') {
|
if (ctrl.settings.RedirectURI === '') {
|
||||||
ctrl.settings.RedirectURI = window.location.origin;
|
ctrl.settings.RedirectURI = window.location.origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctrl.settings.AuthorizationURI !== '') {
|
if (ctrl.settings.AuthorizationURI !== '') {
|
||||||
ctrl.state.provider.authUrl = ctrl.settings.AuthorizationURI;
|
ctrl.state.provider.authUrl = ctrl.settings.AuthorizationURI;
|
||||||
|
|
||||||
if (ctrl.settings.AuthorizationURI.indexOf('login.microsoftonline.com') > -1) {
|
|
||||||
var tenantID = ctrl.settings.AuthorizationURI.match(/login.microsoftonline.com\/(.*?)\//)[1];
|
|
||||||
ctrl.state.microsoftTenantID = tenantID;
|
|
||||||
onMicrosoftTenantIDChange();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,30 +39,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<oauth-providers-selector on-select="($ctrl.onSelectProvider)" provider="$ctrl.state.provider"></oauth-providers-selector>
|
|
||||||
|
|
||||||
<div class="col-sm-12 form-section-title">OAuth Configuration</div>
|
<div class="col-sm-12 form-section-title">OAuth Configuration</div>
|
||||||
|
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name == 'microsoft'">
|
|
||||||
<label for="oauth_microsoft_tenant_id" class="col-sm-3 col-lg-2 control-label text-left">
|
|
||||||
Tenant ID
|
|
||||||
<portainer-tooltip position="bottom" message="ID of the Azure Directory you wish to authenticate against. Also known as the Directory ID"></portainer-tooltip>
|
|
||||||
</label>
|
|
||||||
<div class="col-sm-9 col-lg-10">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="form-control"
|
|
||||||
id="oauth_microsoft_tenant_id"
|
|
||||||
placeholder="xxxxxxxxxxxxxxxxxxxx"
|
|
||||||
ng-model="$ctrl.state.microsoftTenantID"
|
|
||||||
ng-change="$ctrl.onMicrosoftTenantIDChange()"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="oauth_client_id" class="col-sm-3 col-lg-2 control-label text-left">
|
<label for="oauth_client_id" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
{{ $ctrl.state.provider.name == 'microsoft' ? 'Application ID' : 'Client ID' }}
|
Client ID
|
||||||
<portainer-tooltip position="bottom" message="Public identifier of the OAuth application"></portainer-tooltip>
|
<portainer-tooltip position="bottom" message="Public identifier of the OAuth application"></portainer-tooltip>
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-9 col-lg-10">
|
<div class="col-sm-9 col-lg-10">
|
||||||
|
@ -72,14 +53,14 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="oauth_client_secret" class="col-sm-3 col-lg-2 control-label text-left">
|
<label for="oauth_client_secret" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
{{ $ctrl.state.provider.name == 'microsoft' ? 'Application key' : 'Client secret' }}
|
Client secret
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-9 col-lg-10">
|
<div class="col-sm-9 col-lg-10">
|
||||||
<input type="password" class="form-control" id="oauth_client_secret" ng-model="$ctrl.settings.ClientSecret" placeholder="xxxxxxxxxxxxxxxxxxxx" />
|
<input type="password" class="form-control" id="oauth_client_secret" ng-model="$ctrl.settings.ClientSecret" placeholder="xxxxxxxxxxxxxxxxxxxx" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name == 'custom' || $ctrl.state.overrideConfiguration">
|
<div class="form-group">
|
||||||
<label for="oauth_authorization_uri" class="col-sm-3 col-lg-2 control-label text-left">
|
<label for="oauth_authorization_uri" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
Authorization URL
|
Authorization URL
|
||||||
<portainer-tooltip
|
<portainer-tooltip
|
||||||
|
@ -92,7 +73,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name == 'custom' || $ctrl.state.overrideConfiguration">
|
<div class="form-group">
|
||||||
<label for="oauth_access_token_uri" class="col-sm-3 col-lg-2 control-label text-left">
|
<label for="oauth_access_token_uri" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
Access token URL
|
Access token URL
|
||||||
<portainer-tooltip position="bottom" message="URL used by Portainer to exchange a valid OAuth authentication code for an access token"></portainer-tooltip>
|
<portainer-tooltip position="bottom" message="URL used by Portainer to exchange a valid OAuth authentication code for an access token"></portainer-tooltip>
|
||||||
|
@ -102,7 +83,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name == 'custom' || $ctrl.state.overrideConfiguration">
|
<div class="form-group">
|
||||||
<label for="oauth_resource_uri" class="col-sm-3 col-lg-2 control-label text-left">
|
<label for="oauth_resource_uri" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
Resource URL
|
Resource URL
|
||||||
<portainer-tooltip position="bottom" message="URL used by Portainer to retrieve information about the authenticated user"></portainer-tooltip>
|
<portainer-tooltip position="bottom" message="URL used by Portainer to retrieve information about the authenticated user"></portainer-tooltip>
|
||||||
|
@ -112,7 +93,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name == 'custom' || $ctrl.state.overrideConfiguration">
|
<div class="form-group">
|
||||||
<label for="oauth_redirect_uri" class="col-sm-3 col-lg-2 control-label text-left">
|
<label for="oauth_redirect_uri" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
Redirect URL
|
Redirect URL
|
||||||
<portainer-tooltip
|
<portainer-tooltip
|
||||||
|
@ -125,7 +106,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name == 'custom' || $ctrl.state.overrideConfiguration">
|
<div class="form-group">
|
||||||
<label for="oauth_user_identifier" class="col-sm-3 col-lg-2 control-label text-left">
|
<label for="oauth_user_identifier" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
User identifier
|
User identifier
|
||||||
<portainer-tooltip
|
<portainer-tooltip
|
||||||
|
@ -138,7 +119,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name == 'custom' || $ctrl.state.overrideConfiguration">
|
<div class="form-group">
|
||||||
<label for="oauth_scopes" class="col-sm-3 col-lg-2 control-label text-left">
|
<label for="oauth_scopes" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
Scopes
|
Scopes
|
||||||
<portainer-tooltip
|
<portainer-tooltip
|
||||||
|
@ -150,15 +131,4 @@
|
||||||
<input type="text" class="form-control" id="oauth_scopes" ng-model="$ctrl.settings.Scopes" placeholder="id,email,name" />
|
<input type="text" class="form-control" id="oauth_scopes" ng-model="$ctrl.settings.Scopes" placeholder="id,email,name" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name != 'custom'">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<a class="small interactive" ng-if="!$ctrl.state.overrideConfiguration" ng-click="$ctrl.state.overrideConfiguration = true;">
|
|
||||||
<i class="fa fa-wrench space-right" aria-hidden="true"></i> Override default configuration
|
|
||||||
</a>
|
|
||||||
<a class="small interactive" ng-if="$ctrl.state.overrideConfiguration" ng-click="$ctrl.state.overrideConfiguration = false; $ctrl.useDefaultProviderConfiguration()">
|
|
||||||
<i class="fa fa-cogs space-right" aria-hidden="true"></i> Use default configuration
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue