feat: add OIDC authentication for server mode
This commit is contained in:
@@ -83,6 +83,40 @@ func FindAndOpenSQLiteStore() (Store, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// FindOrInitSQLiteStore is like FindAndOpenSQLiteStore but intended for server
|
||||
// mode: if no .ax.db is found it creates and initialises one in the current
|
||||
// working directory instead of returning an error.
|
||||
func FindOrInitSQLiteStore() (Store, error) {
|
||||
if dbpath := os.Getenv("AX_DB_PATH"); dbpath != "" {
|
||||
if err := InitSQLiteStore(dbpath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewSQLiteStore(dbpath)
|
||||
}
|
||||
dir, err := filepath.Abs(".")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for {
|
||||
dbpath := filepath.Join(dir, ".ax.db")
|
||||
if _, err := os.Stat(dbpath); err == nil {
|
||||
return NewSQLiteStore(dbpath)
|
||||
}
|
||||
if parent := filepath.Dir(dir); parent == dir {
|
||||
break
|
||||
} else {
|
||||
dir = parent
|
||||
}
|
||||
}
|
||||
// Not found — create and initialise in CWD.
|
||||
cwd, _ := filepath.Abs(".")
|
||||
dbpath := filepath.Join(cwd, ".ax.db")
|
||||
if err := InitSQLiteStore(dbpath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewSQLiteStore(dbpath)
|
||||
}
|
||||
|
||||
// NewSQLiteStore opens a SQLite database at the given path, runs a one-time
|
||||
// schema migration if needed, then applies per-connection PRAGMAs.
|
||||
func NewSQLiteStore(path string) (Store, error) {
|
||||
|
||||
Reference in New Issue
Block a user