mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-09-13 14:18:38 -04:00
Introducing gowrap as a build-time tool to generate interface delegate structs from templates: * added as a 'make go-generate' target in services/graph, * added as a build-time dependency in .bingo/ Introduce an LDAP client abstraction interface to be able to wrap the go-ldap client API with metrics transparently (and possibly hooks and such in the future), in order to use delegation patterns to measure the time LDAP (client) operations take to finish, as well as to track their results (success, failure, not-found). Has two implementations that are generated using gowrap: * a go-ldap adapter implementation that directly delegates to a go-ldap connection * a time measuring and metrics collecting implementation that delegates to another LdapClient The metrics collecting one is disabled by default, can be enabled with GRAPH_LDAP_METRICS_DISABLE=false It collects durations of outbound LDAP client operations into a histogram, as well as the number of concurrent outbound LDAP operations in a gauge (via an atomic int and a gauge function, as that performs best). Add an HTTP middleware that measures how long Graph HTTP API requests take, storing taken time into a histogram along with labels for * method, * path pattern (from the chi routes), * Graph API version prefix, * Graph API resource name, * and the resulting status code. It also tracks the number of concurrent inbound Graph API HTTP requests using a gauge (also using an atomic int and a gauge function). Disabled by default, can be enabled with GRAPH_HTTP_METRICS_DISABLE=false Add Backend and EducationBackend delegate implementations that measure execution time on the level of the higher API call operations there (CreateUser, DeleteUser, ..., CreateSchool, ...), generated using gowrap. Disabled by default, can be enabled with GRAPH_IDENTITY_BACKEND_METRICS_DISABLE=false Also added a small k6 script to produce some read-only load on the Graph API, for a casual test of the metrics, as well as k6 in mise.toml. Make an internal changes to how singular LDAP entry searches work in the LDAP identity backends: * check whether searches for a singular entry returns more than one result, in which case a new error TooManyResults is returned, instead of leaving that undetected, blindly taking the first result, and potentially risking data inconsistencies Improve the loggers in identity backends by adding attributes for their request targets (Reva gateway address or LDAP URI, respectively). Also add a "backend" attribute for all Graph API logs (set to "ldap" or "cs3"), to help debug potential issues, and remove them from all the logger debug calls at the beginning of each LDAP-related function as those should really be part of the logger and set beforehand. The LDAP identity backend logger also has two new attributes to help debugging with logs: * write (bool): whether write operations are enabled * refint (bool): whether refint is enabled or not Also adds a dedicated counter metric for user password change operations. Minor campfire improvements: * add a constructor func for the CS3 backend * add a constructor func for the LDAP backend * in the LDAP identity backend, in searchLDAPEntryByFilter (used by all search/get public functions), errors that occur when performing LDAP SEARCH operations were blindly mapped to a ItemNotFound error, instead of being analyzed as it could be caused by a technical error * in the requireadmin middleware, add debug logging to explain why a request is denied * when an LDAP password change fails because the user entry was not found in LDAP, we now have a log message that tracks that
148 lines
6.9 KiB
Go
148 lines
6.9 KiB
Go
package identity
|
|
|
|
import (
|
|
"context"
|
|
|
|
libregraph "github.com/opencloud-eu/libre-graph-api-go"
|
|
)
|
|
|
|
// ErrEducationBackend is a dummy EducationBackend, doing nothing
|
|
type ErrEducationBackend struct{}
|
|
|
|
var _ EducationBackend = &ErrEducationBackend{}
|
|
|
|
// CreateEducationSchool creates the supplied school in the identity backend.
|
|
func (i *ErrEducationBackend) CreateEducationSchool(ctx context.Context, school libregraph.EducationSchool) (*libregraph.EducationSchool, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// DeleteEducationSchool deletes a given school, identified by id
|
|
func (i *ErrEducationBackend) DeleteEducationSchool(ctx context.Context, id string) error {
|
|
return errNotImplemented
|
|
}
|
|
|
|
// GetEducationSchool implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) GetEducationSchool(ctx context.Context, nameOrID string) (*libregraph.EducationSchool, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// GetEducationSchools implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) GetEducationSchools(ctx context.Context) ([]*libregraph.EducationSchool, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// FilterEducationSchoolsByAttribute implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) FilterEducationSchoolsByAttribute(ctx context.Context, attr, value string) ([]*libregraph.EducationSchool, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// UpdateEducationSchool implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) UpdateEducationSchool(ctx context.Context, numberOrID string, school libregraph.EducationSchool) (*libregraph.EducationSchool, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// GetEducationSchoolUsers implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) GetEducationSchoolUsers(ctx context.Context, id string) ([]*libregraph.EducationUser, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// GetEducationSchoolClasses implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) GetEducationSchoolClasses(ctx context.Context, schoolNumberOrID string) ([]*libregraph.EducationClass, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// AddClassesToEducationSchool implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) AddClassesToEducationSchool(ctx context.Context, schoolNumberOrID string, memberIDs []string) error {
|
|
return errNotImplemented
|
|
}
|
|
|
|
// RemoveClassFromEducationSchool implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) RemoveClassFromEducationSchool(ctx context.Context, schoolNumberOrID string, memberID string) error {
|
|
return errNotImplemented
|
|
}
|
|
|
|
// AddUsersToEducationSchool adds new members (reference by a slice of IDs) to supplied school in the identity backend.
|
|
func (i *ErrEducationBackend) AddUsersToEducationSchool(ctx context.Context, schoolID string, memberID []string) error {
|
|
return errNotImplemented
|
|
}
|
|
|
|
// RemoveUserFromEducationSchool removes a single member (by ID) from a school
|
|
func (i *ErrEducationBackend) RemoveUserFromEducationSchool(ctx context.Context, schoolID string, memberID string) error {
|
|
return errNotImplemented
|
|
}
|
|
|
|
// GetEducationClasses implements the EducationBackend interface
|
|
func (i *ErrEducationBackend) GetEducationClasses(ctx context.Context) ([]*libregraph.EducationClass, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// GetEducationClass implements the EducationBackend interface
|
|
func (i *ErrEducationBackend) GetEducationClass(ctx context.Context, namedOrID string) (*libregraph.EducationClass, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// CreateEducationClass implements the EducationBackend interface
|
|
func (i *ErrEducationBackend) CreateEducationClass(ctx context.Context, class libregraph.EducationClass) (*libregraph.EducationClass, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// DeleteEducationClass implements the EducationBackend interface
|
|
func (i *ErrEducationBackend) DeleteEducationClass(ctx context.Context, nameOrID string) error {
|
|
return errNotImplemented
|
|
}
|
|
|
|
// GetEducationClassMembers implements the EducationBackend interface
|
|
func (i *ErrEducationBackend) GetEducationClassMembers(ctx context.Context, nameOrID string) ([]*libregraph.EducationUser, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// UpdateEducationClass implements the EducationBackend interface
|
|
func (i *ErrEducationBackend) UpdateEducationClass(ctx context.Context, id string, class libregraph.EducationClass) (*libregraph.EducationClass, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// CreateEducationUser creates a given education user in the identity backend.
|
|
func (i *ErrEducationBackend) CreateEducationUser(ctx context.Context, user libregraph.EducationUser) (*libregraph.EducationUser, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// DeleteEducationUser deletes a given education user, identified by username or id, from the backend
|
|
func (i *ErrEducationBackend) DeleteEducationUser(ctx context.Context, nameOrID string) error {
|
|
return errNotImplemented
|
|
}
|
|
|
|
// UpdateEducationUser applies changes to given education user, identified by username or id
|
|
func (i *ErrEducationBackend) UpdateEducationUser(ctx context.Context, nameOrID string, user libregraph.EducationUser) (*libregraph.EducationUser, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// GetEducationUser implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) GetEducationUser(ctx context.Context, nameOrID string) (*libregraph.EducationUser, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// GetEducationUsers implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) GetEducationUsers(ctx context.Context) ([]*libregraph.EducationUser, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// FilterEducationUsersByAttribute implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) FilterEducationUsersByAttribute(ctx context.Context, attr, value string) ([]*libregraph.EducationUser, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// GetEducationClassTeachers implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) GetEducationClassTeachers(ctx context.Context, classID string) ([]*libregraph.EducationUser, error) {
|
|
return nil, errNotImplemented
|
|
}
|
|
|
|
// AddTeacherToEducationClass implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) AddTeacherToEducationClass(ctx context.Context, classID string, teacherID string) error {
|
|
return errNotImplemented
|
|
}
|
|
|
|
// RemoveTeacherFromEducationClass implements the EducationBackend interface for the ErrEducationBackend backend.
|
|
func (i *ErrEducationBackend) RemoveTeacherFromEducationClass(ctx context.Context, classID string, teacherID string) error {
|
|
return errNotImplemented
|
|
}
|