mirror of https://github.com/portainer/portainer
refactor(auth): expose only the login url
parent
4cbde7bb0d
commit
24f066716b
|
@ -1,6 +1,7 @@
|
||||||
package settings
|
package settings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
httperror "github.com/portainer/libhttp/error"
|
httperror "github.com/portainer/libhttp/error"
|
||||||
|
@ -15,10 +16,7 @@ type publicSettingsResponse struct {
|
||||||
AllowPrivilegedModeForRegularUsers bool `json:"AllowPrivilegedModeForRegularUsers"`
|
AllowPrivilegedModeForRegularUsers bool `json:"AllowPrivilegedModeForRegularUsers"`
|
||||||
EnableHostManagementFeatures bool `json:"EnableHostManagementFeatures"`
|
EnableHostManagementFeatures bool `json:"EnableHostManagementFeatures"`
|
||||||
ExternalTemplates bool `json:"ExternalTemplates"`
|
ExternalTemplates bool `json:"ExternalTemplates"`
|
||||||
AuthorizationURI string `json:"AuthorizationURI"`
|
OAuthLoginURI string `json:"OAuthLoginURI"`
|
||||||
ClientID string `json:"ClientID"`
|
|
||||||
RedirectURI string `json:"RedirectURI"`
|
|
||||||
Scopes string `json:"Scopes"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET request on /api/settings/public
|
// GET request on /api/settings/public
|
||||||
|
@ -35,10 +33,11 @@ func (handler *Handler) settingsPublic(w http.ResponseWriter, r *http.Request) *
|
||||||
AllowPrivilegedModeForRegularUsers: settings.AllowPrivilegedModeForRegularUsers,
|
AllowPrivilegedModeForRegularUsers: settings.AllowPrivilegedModeForRegularUsers,
|
||||||
EnableHostManagementFeatures: settings.EnableHostManagementFeatures,
|
EnableHostManagementFeatures: settings.EnableHostManagementFeatures,
|
||||||
ExternalTemplates: false,
|
ExternalTemplates: false,
|
||||||
AuthorizationURI: settings.OAuthSettings.AuthorizationURI,
|
OAuthLoginURI: fmt.Sprintf("%s?response_type=code&client_id=%s&redirect_uri=%s&scope=%s&state=portainer",
|
||||||
ClientID: settings.OAuthSettings.ClientID,
|
settings.OAuthSettings.AuthorizationURI,
|
||||||
RedirectURI: settings.OAuthSettings.RedirectURI,
|
settings.OAuthSettings.ClientID,
|
||||||
Scopes: settings.OAuthSettings.Scopes,
|
settings.OAuthSettings.RedirectURI,
|
||||||
|
settings.OAuthSettings.Scopes),
|
||||||
}
|
}
|
||||||
|
|
||||||
if settings.TemplatesURL != "" {
|
if settings.TemplatesURL != "" {
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<!-- login button -->
|
<!-- login button -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<a ng-href="{{ AuthorizationURI }}?response_type=code&client_id={{ ClientID }}&redirect_uri={{ RedirectURI }}&scope={{ Scopes }}&state=portainer"><div class="btn btn-primary btn-sm pull-right" ng-if="AuthenticationMethod === 3" style="margin-left:2px"><i class="fa fa-sign-in-alt" aria-hidden="true"></i> OAuth Login</div></a>
|
<a ng-href="{{OAuthLoginURI}}"><div class="btn btn-primary btn-sm pull-right" ng-if="AuthenticationMethod === 3" style="margin-left:2px"><i class="fa fa-sign-in-alt" aria-hidden="true"></i> OAuth Login</div></a>
|
||||||
<button type="submit" class="btn btn-primary btn-sm pull-right" ng-click="authenticateUser()"><i class="fa fa-sign-in-alt" aria-hidden="true"></i> Login</button>
|
<button type="submit" class="btn btn-primary btn-sm pull-right" ng-click="authenticateUser()"><i class="fa fa-sign-in-alt" aria-hidden="true"></i> Login</button>
|
||||||
<span class="pull-left" style="margin: 5px;" ng-if="state.AuthenticationError">
|
<span class="pull-left" style="margin: 5px;" ng-if="state.AuthenticationError">
|
||||||
<i class="fa fa-exclamation-triangle red-icon" aria-hidden="true" style="margin-right: 2px;"></i>
|
<i class="fa fa-exclamation-triangle red-icon" aria-hidden="true" style="margin-right: 2px;"></i>
|
||||||
|
|
|
@ -84,10 +84,7 @@ function (urlHelper, $q, $scope, $state, $stateParams, $sanitize, Authentication
|
||||||
SettingsService.publicSettings()
|
SettingsService.publicSettings()
|
||||||
.then(function success(settings) {
|
.then(function success(settings) {
|
||||||
$scope.AuthenticationMethod = settings.AuthenticationMethod;
|
$scope.AuthenticationMethod = settings.AuthenticationMethod;
|
||||||
$scope.ClientID = settings.ClientID;
|
$scope.OAuthLoginURI = settings.OAuthLoginURI;
|
||||||
$scope.RedirectURI = settings.RedirectURI;
|
|
||||||
$scope.Scopes = settings.Scopes;
|
|
||||||
$scope.AuthorizationURI = settings.AuthorizationURI;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($stateParams.logout || $stateParams.error) {
|
if ($stateParams.logout || $stateParams.error) {
|
||||||
|
|
Loading…
Reference in New Issue