Compare commits

...
2 Commits
Author SHA1 Message Date
Graham Steffaniak 91b9515056 updated with small change (#616) 2025-05-09 11:47:24 -05:00
Graham Steffaniak 224a273066 revert enforced login method (#612) 2025-05-09 11:00:54 -05:00
8 changed files with 62 additions and 15 deletions

No files matched your search

+13
View File
@@ -2,6 +2,19 @@
All notable changes to this project will be documented in this file. For commit guidelines, please refer to [Standard Version](https://github.com/conventional-changelog/standard-version).
## v0.7.2-beta
The `media` tags introduced in 0.7.0 have been removed -- all docker images have media enabled now.
**Notes**:
- Reverts enforced user login methods types -- until suitable methods to alter are available.
- When updating a user, updating scope always sets to the exact scope specified on updated.
- Redirect api messages are INFO instead of WARN
- Settings has close button instead of back https://github.com/gtsteffaniak/filebrowser/issues/583
**Bug Fixes**:
- Hover bug when exact timestamp setting enabled https://github.com/gtsteffaniak/filebrowser/issues/585
## v0.7.1-beta
The `media` tags introduced in 0.7.0 have been removed -- all docker images have media enabled now.
+5 -5
View File
@@ -17,7 +17,7 @@ func MakeUserDir(fullPath string) error {
return nil
}
func MakeUserDirs(u *users.User) error {
func MakeUserDirs(u *users.User, disableScopeChange bool) error {
cleanedUserName := users.CleanUsername(u.Username)
if cleanedUserName == "" || cleanedUserName == "-" || cleanedUserName == "." {
return fmt.Errorf("create user: invalid user for home dir creation: [%s]", u.Username)
@@ -28,7 +28,7 @@ func MakeUserDirs(u *users.User) error {
return fmt.Errorf("create user: source not found: %s", scope.Name)
}
// create directory and append user name
if filepath.Base(scope.Scope) != cleanedUserName && source.Config.CreateUserDir {
if filepath.Base(scope.Scope) != cleanedUserName && source.Config.CreateUserDir && !disableScopeChange {
fullPath := filepath.Join(source.Path, scope.Scope, cleanedUserName)
parentDir := filepath.Join(source.Path, scope.Scope)
// validate that scope path exists
@@ -53,9 +53,9 @@ func MakeUserDirs(u *users.User) error {
}
} else {
// just assigning scope to path provided, so just check that it exists
parentDir := filepath.Join(source.Path, scope.Scope)
if !Exists(parentDir) {
return fmt.Errorf("create user: parent folder does not exist: %s", parentDir)
path := filepath.Join(source.Path, scope.Scope)
if !Exists(path) {
return fmt.Errorf("create user: scope folder does not exist: %s", path)
}
}
u.Scopes[i] = scope
+2 -1
View File
@@ -96,7 +96,8 @@ func Log(level string, msg string, prefix, api bool, color string) {
}
func Api(msg string, statusCode int) {
if statusCode >= 300 && statusCode < 500 {
// redirects are not warnings anymore
if statusCode > 302 && statusCode < 500 {
Log(levels.WARNING, msg, false, true, YELLOW)
} else if statusCode >= 500 {
Log(levels.ERROR, msg, false, true, RED)
+2 -2
View File
@@ -100,7 +100,7 @@ func (st usersBackend) Update(user *users.User, actorIsAdmin bool, fields ...str
return err
}
user.Scopes = adjustedScopes
err = files.MakeUserDirs(user)
err = files.MakeUserDirs(user, true)
if err != nil {
return err
}
@@ -159,7 +159,7 @@ func (st usersBackend) Save(user *users.User, changePass bool) error {
return err
}
user.Scopes = adjustedScopes
err = files.MakeUserDirs(user)
err = files.MakeUserDirs(user, false)
if err != nil {
logger.Error(err.Error())
}
+26 -5
View File
@@ -102,7 +102,14 @@ func setupProxyUser(r *http.Request, data *requestContext, proxyUser string) (*u
}
}
if data.user.LoginMethod != users.LoginMethodProxy {
return nil, fmt.Errorf("user %s is not allowed to login with proxy authentication", proxyUser)
logger.Warning(fmt.Sprintf("user %s is not allowed to login with proxy authentication, bypassing and updating login method", data.user.Username))
data.user.LoginMethod = users.LoginMethodProxy
// Perform the user update
err := store.Users.Update(data.user, true, "LoginMethod")
if err != nil {
logger.Debug(err.Error())
}
//return nil, fmt.Errorf("user %s is not allowed to login with proxy authentication", proxyUser)
}
return data.user, nil
}
@@ -151,8 +158,15 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
return
}
if user.LoginMethod != users.LoginMethodPassword {
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
return
logger.Warning(fmt.Sprintf("user %s is not allowed to login with password authentication, bypassing and updating login method", user.Username))
user.LoginMethod = users.LoginMethodPassword
// Perform the user update
err = store.Users.Update(user, true, "LoginMethod")
if err != nil {
logger.Debug(err.Error())
}
//http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
//return
}
status, err := printToken(w, r, user) // Pass the data object
@@ -540,11 +554,12 @@ func oidcLoginHandler(w http.ResponseWriter, r *http.Request, d *requestContext)
redirectURI := fmt.Sprintf("%s/api/auth/oidc/callback", origin)
// Construct the authorization URL
authURL := fmt.Sprintf("%s?client_id=%s&response_type=code&scope=%s&redirect_uri=%s&state=%s",
authURL := fmt.Sprintf("%s?client_id=%s&response_type=code&scope=%s&redirect_uri=%s&redirect_uris=%s&state=%s",
config.Auth.Methods.OidcAuth.AuthorizationUrl,
url.QueryEscape(config.Auth.Methods.OidcAuth.ClientID),
url.QueryEscape(config.Auth.Methods.OidcAuth.Scopes),
url.QueryEscape(redirectURI),
url.QueryEscape(redirectURI),
url.QueryEscape(state), // Use the state parameter
)
@@ -595,7 +610,13 @@ func loginWithOidcUser(w http.ResponseWriter, r *http.Request, userInfo userInfo
}
}
if user.LoginMethod != users.LoginMethodOidc {
return http.StatusForbidden, fmt.Errorf("user %s is not allowed to login with OIDC", username)
logger.Warning(fmt.Sprintf("user %s is not allowed to login with oidc authentication, bypassing and updating login method", user.Username))
user.LoginMethod = users.LoginMethodOidc
err = store.Users.Update(user, true, "LoginMethod")
if err != nil {
logger.Debug(err.Error())
}
//return http.StatusForbidden, fmt.Errorf("user %s is not allowed to login with OIDC", username)
}
signed, err := makeSignedTokenAPI(user, "WEB_TOKEN_"+utils.InsecureRandomIdentifier(4), time.Hour*time.Duration(config.Auth.TokenExpirationHours), user.Permissions)
if err != nil {
+7 -1
View File
@@ -49,6 +49,9 @@ export default {
return state.req;
},
multistate() {
if (!state.multiButtonState) {
return "close";
}
return state.multiButtonState;
},
stickSidebar() {
@@ -65,13 +68,16 @@ export default {
req() {
this.reEvalAction()
},
currentView() {
this.reEvalAction()
},
},
methods: {
reEvalAction() {
const currentView = getters.currentView()
if (currentView == "settings" ) {
mutations.setActiveSettingsView(getters.currentHash());
mutations.setMultiButtonState("back")
mutations.setMultiButtonState("close")
} else if (currentView == "editor" || currentView == "preview" || currentView == "onlyOfficeEditor" || currentView == "markdownViewer") {
mutations.setMultiButtonState("close")
} else {
+2 -1
View File
@@ -173,6 +173,7 @@ import { signup, disableExternal, noAuth, loginPage } from "@/utils/constants";
import ProgressBar from "@/components/ProgressBar.vue";
import { state, getters, mutations } from "@/store"; // Import your custom store
import { getHumanReadableFilesize } from "@/utils/filesizes.js";
import { fromNow } from "@/utils/moment";
export default {
name: "SidebarGeneral",
@@ -226,7 +227,7 @@ export default {
if (val === 0) {
return "now";
}
return getters.getTime(val);
return fromNow(val, state.user.locale);
},
},
watch: {
+5
View File
@@ -119,12 +119,17 @@ export default {
mutations.toggleSidebar();
} else {
mutations.closeHovers();
if (listingView === "settings") {
router.push({path: "/files" });
return;
}
if (listingView === "onlyOfficeEditor") {
const current = window.location.pathname;
const newpath = removeLastDir(current);
window.location = newpath + "#" + state.req.name;
return;
}
mutations.replaceRequest({});
router.go(-1);
}