mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
d1d02d9eae
* Redirect to default URL after 1FA when default policy is one_factor. User is now redirected to the default redirection URL after 1FA if the default policy is set to one_factor and there is no target URL or if the target URL is unsafe. Also, if the default policy is set to one_factor and the user is already authenticated, if she visits the login portal, the 'already authenticated' view is displayed with a logout button. This fixes #581. * Update users.yml * Fix permissions issue causing suite test failure
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package handlers
|
|
|
|
import (
|
|
"github.com/authelia/authelia/internal/authentication"
|
|
"github.com/authelia/authelia/internal/authorization"
|
|
"github.com/authelia/authelia/internal/middlewares"
|
|
)
|
|
|
|
type ExtendedConfigurationBody struct {
|
|
AvailableMethods MethodList `json:"available_methods"`
|
|
|
|
// OneFactorDefaultPolicy is set if default policy is 'one_factor'
|
|
OneFactorDefaultPolicy bool `json:"one_factor_default_policy"`
|
|
}
|
|
|
|
// ExtendedConfigurationGet get the extended configuration accessible to authenticated users.
|
|
func ExtendedConfigurationGet(ctx *middlewares.AutheliaCtx) {
|
|
body := ExtendedConfigurationBody{}
|
|
body.AvailableMethods = MethodList{authentication.TOTP, authentication.U2F}
|
|
|
|
if ctx.Configuration.DuoAPI != nil {
|
|
body.AvailableMethods = append(body.AvailableMethods, authentication.Push)
|
|
}
|
|
|
|
defaultPolicy := authorization.PolicyToLevel(ctx.Configuration.AccessControl.DefaultPolicy)
|
|
body.OneFactorDefaultPolicy = defaultPolicy == authorization.OneFactor
|
|
ctx.Logger.Tracef("Default policy set to one factor: %v", body.OneFactorDefaultPolicy)
|
|
|
|
ctx.Logger.Tracef("Available methods are %s", body.AvailableMethods)
|
|
ctx.SetJSONBody(body)
|
|
}
|