Auth: Use auth broker by default (#69620)

remove authnservice toggle
This commit is contained in:
Jo
2023-06-07 08:57:41 +02:00
committed by GitHub
parent e17ef5e504
commit aee5c6dea0
12 changed files with 27 additions and 29 deletions
+1 -1
View File
@@ -617,7 +617,7 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
m.UseMiddleware(hs.ContextHandler.Middleware)
m.Use(middleware.OrgRedirect(hs.Cfg, hs.userService))
if !hs.Features.IsEnabled(featuremgmt.FlagAuthnService) {
if !hs.Cfg.AuthBrokerEnabled {
m.Use(accesscontrol.LoadPermissionsMiddleware(hs.accesscontrolService))
}
+1 -1
View File
@@ -194,7 +194,7 @@ func (hs *HTTPServer) LoginAPIPing(c *contextmodel.ReqContext) response.Response
}
func (hs *HTTPServer) LoginPost(c *contextmodel.ReqContext) response.Response {
if hs.Features.IsEnabled(featuremgmt.FlagAuthnService) {
if hs.Cfg.AuthBrokerEnabled {
identity, err := hs.authnService.Login(c.Req.Context(), authn.ClientForm, &authn.Request{HTTPRequest: c.Req, Resp: c.Resp})
if err != nil {
tokenErr := &auth.CreateTokenErr{}
+3 -4
View File
@@ -19,7 +19,6 @@ import (
"github.com/grafana/grafana/pkg/middleware/cookies"
"github.com/grafana/grafana/pkg/services/authn"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/featuremgmt"
loginservice "github.com/grafana/grafana/pkg/services/login"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/user"
@@ -84,7 +83,7 @@ func (hs *HTTPServer) OAuthLogin(ctx *contextmodel.ReqContext) {
code := ctx.Query("code")
if hs.Features.IsEnabled(featuremgmt.FlagAuthnService) {
if hs.Cfg.AuthBrokerEnabled {
req := &authn.Request{HTTPRequest: ctx.Req, Resp: ctx.Resp}
if code == "" {
redirect, err := hs.authnService.RedirectURL(ctx.Req.Context(), authn.ClientWithPrefix(name), req)
@@ -381,7 +380,7 @@ func (hs *HTTPServer) handleOAuthLoginError(ctx *contextmodel.ReqContext, info l
ctx.Handle(hs.Cfg, err.HttpStatus, err.PublicMessage, err.Err)
// login hooks is handled by authn.Service
if !hs.Features.IsEnabled(featuremgmt.FlagAuthnService) {
if !hs.Cfg.AuthBrokerEnabled {
info.Error = err.Err
if info.Error == nil {
info.Error = errors.New(err.PublicMessage)
@@ -396,7 +395,7 @@ func (hs *HTTPServer) handleOAuthLoginErrorWithRedirect(ctx *contextmodel.ReqCon
hs.redirectWithError(ctx, err, v...)
// login hooks is handled by authn.Service
if !hs.Features.IsEnabled(featuremgmt.FlagAuthnService) {
if !hs.Cfg.AuthBrokerEnabled {
info.Error = err
hs.HooksService.RunLoginHook(&info, ctx)
}