mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-19 15:23:36 +00:00
Ref: https://opensubsonic.netlify.app/docs/extensions/apikeyauth/. Add functionality for users to create, manage, and use API keys for authentication. * **Database:** * Added a new `api_key`(`20250415111500_add_api_key_table.go`) table to store API keys associated with users. * **Backend:** * Defined the `APIKey` model. * Implemented `APIKeyRepository` for database operations. * Added `FindByAPIKey` method to `UserRepository` to allow user lookup via API key. * Updated Subsonic API error responses to include API key-related errors and messaging. * Integrated API key authentication into the subsonic authentication middleware. * **UI:** * Added new React components for API Key CRUD operations: `ApiKeyList`, `ApiKeyCreate`, and `ApiKeyEdit`. * The API Key management section can be accessed from the settings menu. # Conflicts: # model/user.go # server/subsonic/middlewares.go # server/subsonic/middlewares_test.go # tests/mock_data_store.go # tests/mock_user_repo.go
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/Masterminds/squirrel"
|
|
"github.com/deluan/rest"
|
|
)
|
|
|
|
type QueryOptions struct {
|
|
Sort string
|
|
Order string
|
|
Max int
|
|
Offset int
|
|
Filters squirrel.Sqlizer
|
|
Seed string // for random sorting
|
|
}
|
|
|
|
type ResourceRepository interface {
|
|
rest.Repository
|
|
}
|
|
|
|
type DataStore interface {
|
|
Library(ctx context.Context) LibraryRepository
|
|
Folder(ctx context.Context) FolderRepository
|
|
Album(ctx context.Context) AlbumRepository
|
|
Artist(ctx context.Context) ArtistRepository
|
|
MediaFile(ctx context.Context) MediaFileRepository
|
|
Genre(ctx context.Context) GenreRepository
|
|
Tag(ctx context.Context) TagRepository
|
|
Playlist(ctx context.Context) PlaylistRepository
|
|
PlayQueue(ctx context.Context) PlayQueueRepository
|
|
Transcoding(ctx context.Context) TranscodingRepository
|
|
Player(ctx context.Context) PlayerRepository
|
|
Radio(ctx context.Context) RadioRepository
|
|
Share(ctx context.Context) ShareRepository
|
|
Property(ctx context.Context) PropertyRepository
|
|
User(ctx context.Context) UserRepository
|
|
UserProps(ctx context.Context) UserPropsRepository
|
|
ScrobbleBuffer(ctx context.Context) ScrobbleBufferRepository
|
|
APIKey(ctx context.Context) APIKeyRepository
|
|
|
|
Resource(ctx context.Context, model interface{}) ResourceRepository
|
|
|
|
WithTx(block func(tx DataStore) error, scope ...string) error
|
|
WithTxImmediate(block func(tx DataStore) error, scope ...string) error
|
|
GC(ctx context.Context) error
|
|
}
|