authelia/internal/utils/files.go
James Elliott ddea31193b
feature(oidc): add support for OpenID Connect
OpenID connect has become a standard when it comes to authentication and
in order to fix a security concern around forwarding authentication and authorization information
it has been decided to add support for it.

This feature is in beta version and only enabled when there is a configuration for it.
Before enabling it in production, please consider that it's in beta with potential bugs and that there
are several production critical features still missing such as all OIDC related data is stored in
configuration or memory. This means you are potentially going to experience issues with HA
deployments, or when restarting a single instance specifically related to OIDC.

We are still working on adding the remaining set of features before making it GA as soon as possible.

Related to #189

Co-authored-by: Clement Michaud <clement.michaud34@gmail.com>
2021-05-05 00:15:36 +02:00

57 lines
971 B
Go

package utils
import (
"errors"
"os"
)
// FileExists returns true if the given path exists and is a file.
func FileExists(path string) (exists bool, err error) {
info, err := os.Stat(path)
if err == nil {
if info.IsDir() {
return false, errors.New("path is a directory")
}
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
// DirectoryExists returns true if the given path exists and is a directory.
func DirectoryExists(path string) (exists bool, err error) {
info, err := os.Stat(path)
if err == nil {
if info.IsDir() {
return true, nil
}
return false, errors.New("path is a file")
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
// PathExists returns true if the given path exists.
func PathExists(path string) (exists bool, err error) {
_, err = os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return true, err
}