mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-28 07:56:35 +01:00
* ent re-generation
* add oidc integration
* document oidc integration
* go fmt
* address backend linter findings
* run prettier on index.vue
* State cookie domain can mismatch when Hostname override is used (breaks CSRF check). Add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Delete state cookie with matching domain and MaxAge; add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Fix endpoint path in comments and error to include /api/v1.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Also use request context when verifying the ID token.
* Do not return raw auth errors to clients (user-enumeration risk).
* consistently set cookie the same way across function
* remove baseURL after declaration
* only enable OIDC routes if OIDC is enabled
* swagger doc for failure
* Only block when provider=local; move the check after parsing provider
* fix extended session comment
* reduce pii logging
* futher reduce pii logging
* remove unused DiscoveryDocument
* remove unused offline_access from default oidc scopes
* remove offline access from AuthCodeURL
* support host from X-Forwarded-Host
* set sane default claim names if unset
* error strings should not be capitalized
* Revert "run prettier on index.vue"
This reverts commit aa22330a23.
* Add timeout to provider discovery
* Split scopes robustly
* refactor hostname calculation
* address frontend prettier findings
* add property oidc on type APISummary
* LoginOIDC: Normalize inputs, only create if not found
* add oidc email verification
* oidc handleCallback: clear state cookie before each return
* add support for oidc nonce parameter
* Harden first-login race: handle concurrent creates gracefully and fix log key.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* support email verified claim as bool or string
* fail fast on empty email
* PKCE verifier
* fix: add timing delay to attachment test to resolve CI race condition
The attachment test was failing intermittently in CI due to a race condition
between attachment creation and retrieval. Adding a small 100ms delay after
attachment creation ensures the file system and database operations complete
before the test attempts to verify the attachment exists.
* Revert "fix: add timing delay to attachment test to resolve CI race condition"
This reverts commit 4aa8b2a0d829753e8d2dd1ba76f4b1e04e28c45e.
* oidc error state, use ref
* rename oidc.force to oidc.authRedirect
* remove hardcoded oidc error timeout
* feat: sub/iss based identity matching and userinfo endpoint collection
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
297 lines
10 KiB
Go
Generated
297 lines
10 KiB
Go
Generated
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/google/uuid"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
|
)
|
|
|
|
// User is the model entity for the User schema.
|
|
type User struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// UpdatedAt holds the value of the "updated_at" field.
|
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// Email holds the value of the "email" field.
|
|
Email string `json:"email,omitempty"`
|
|
// Password holds the value of the "password" field.
|
|
Password *string `json:"-"`
|
|
// IsSuperuser holds the value of the "is_superuser" field.
|
|
IsSuperuser bool `json:"is_superuser,omitempty"`
|
|
// Superuser holds the value of the "superuser" field.
|
|
Superuser bool `json:"superuser,omitempty"`
|
|
// Role holds the value of the "role" field.
|
|
Role user.Role `json:"role,omitempty"`
|
|
// ActivatedOn holds the value of the "activated_on" field.
|
|
ActivatedOn time.Time `json:"activated_on,omitempty"`
|
|
// OidcIssuer holds the value of the "oidc_issuer" field.
|
|
OidcIssuer *string `json:"oidc_issuer,omitempty"`
|
|
// OidcSubject holds the value of the "oidc_subject" field.
|
|
OidcSubject *string `json:"oidc_subject,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the UserQuery when eager-loading is set.
|
|
Edges UserEdges `json:"edges"`
|
|
group_users *uuid.UUID
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// UserEdges holds the relations/edges for other nodes in the graph.
|
|
type UserEdges struct {
|
|
// Group holds the value of the group edge.
|
|
Group *Group `json:"group,omitempty"`
|
|
// AuthTokens holds the value of the auth_tokens edge.
|
|
AuthTokens []*AuthTokens `json:"auth_tokens,omitempty"`
|
|
// Notifiers holds the value of the notifiers edge.
|
|
Notifiers []*Notifier `json:"notifiers,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [3]bool
|
|
}
|
|
|
|
// GroupOrErr returns the Group value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e UserEdges) GroupOrErr() (*Group, error) {
|
|
if e.Group != nil {
|
|
return e.Group, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: group.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "group"}
|
|
}
|
|
|
|
// AuthTokensOrErr returns the AuthTokens value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e UserEdges) AuthTokensOrErr() ([]*AuthTokens, error) {
|
|
if e.loadedTypes[1] {
|
|
return e.AuthTokens, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "auth_tokens"}
|
|
}
|
|
|
|
// NotifiersOrErr returns the Notifiers value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e UserEdges) NotifiersOrErr() ([]*Notifier, error) {
|
|
if e.loadedTypes[2] {
|
|
return e.Notifiers, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "notifiers"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*User) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case user.FieldIsSuperuser, user.FieldSuperuser:
|
|
values[i] = new(sql.NullBool)
|
|
case user.FieldName, user.FieldEmail, user.FieldPassword, user.FieldRole, user.FieldOidcIssuer, user.FieldOidcSubject:
|
|
values[i] = new(sql.NullString)
|
|
case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldActivatedOn:
|
|
values[i] = new(sql.NullTime)
|
|
case user.FieldID:
|
|
values[i] = new(uuid.UUID)
|
|
case user.ForeignKeys[0]: // group_users
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the User fields.
|
|
func (_m *User) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case user.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
_m.ID = *value
|
|
}
|
|
case user.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Time
|
|
}
|
|
case user.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
} else if value.Valid {
|
|
_m.UpdatedAt = value.Time
|
|
}
|
|
case user.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
_m.Name = value.String
|
|
}
|
|
case user.FieldEmail:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field email", values[i])
|
|
} else if value.Valid {
|
|
_m.Email = value.String
|
|
}
|
|
case user.FieldPassword:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field password", values[i])
|
|
} else if value.Valid {
|
|
_m.Password = new(string)
|
|
*_m.Password = value.String
|
|
}
|
|
case user.FieldIsSuperuser:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_superuser", values[i])
|
|
} else if value.Valid {
|
|
_m.IsSuperuser = value.Bool
|
|
}
|
|
case user.FieldSuperuser:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field superuser", values[i])
|
|
} else if value.Valid {
|
|
_m.Superuser = value.Bool
|
|
}
|
|
case user.FieldRole:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field role", values[i])
|
|
} else if value.Valid {
|
|
_m.Role = user.Role(value.String)
|
|
}
|
|
case user.FieldActivatedOn:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field activated_on", values[i])
|
|
} else if value.Valid {
|
|
_m.ActivatedOn = value.Time
|
|
}
|
|
case user.FieldOidcIssuer:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field oidc_issuer", values[i])
|
|
} else if value.Valid {
|
|
_m.OidcIssuer = new(string)
|
|
*_m.OidcIssuer = value.String
|
|
}
|
|
case user.FieldOidcSubject:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field oidc_subject", values[i])
|
|
} else if value.Valid {
|
|
_m.OidcSubject = new(string)
|
|
*_m.OidcSubject = value.String
|
|
}
|
|
case user.ForeignKeys[0]:
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
return fmt.Errorf("unexpected type %T for field group_users", values[i])
|
|
} else if value.Valid {
|
|
_m.group_users = new(uuid.UUID)
|
|
*_m.group_users = *value.S.(*uuid.UUID)
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the User.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *User) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryGroup queries the "group" edge of the User entity.
|
|
func (_m *User) QueryGroup() *GroupQuery {
|
|
return NewUserClient(_m.config).QueryGroup(_m)
|
|
}
|
|
|
|
// QueryAuthTokens queries the "auth_tokens" edge of the User entity.
|
|
func (_m *User) QueryAuthTokens() *AuthTokensQuery {
|
|
return NewUserClient(_m.config).QueryAuthTokens(_m)
|
|
}
|
|
|
|
// QueryNotifiers queries the "notifiers" edge of the User entity.
|
|
func (_m *User) QueryNotifiers() *NotifierQuery {
|
|
return NewUserClient(_m.config).QueryNotifiers(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this User.
|
|
// Note that you need to call User.Unwrap() before calling this method if this User
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *User) Update() *UserUpdateOne {
|
|
return NewUserClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the User entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (_m *User) Unwrap() *User {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: User is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *User) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("User(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name=")
|
|
builder.WriteString(_m.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("email=")
|
|
builder.WriteString(_m.Email)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("password=<sensitive>")
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_superuser=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.IsSuperuser))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("superuser=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Superuser))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("role=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Role))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("activated_on=")
|
|
builder.WriteString(_m.ActivatedOn.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
if v := _m.OidcIssuer; v != nil {
|
|
builder.WriteString("oidc_issuer=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := _m.OidcSubject; v != nil {
|
|
builder.WriteString("oidc_subject=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Users is a parsable slice of User.
|
|
type Users []*User
|