Documentation
¶
Index ¶
- func CreateUserInDB(dbPath, username, password string) error
- func DeleteTokenInDB(dbPath, token string) error
- func DeleteUserInDB(dbPath, username string) error
- func PersistClientInDB(dbPath, id string, redirects []string) error
- func PersistTokenInDB(dbPath string, tr TokenRecord) error
- func SetUserPasswordInDB(dbPath, username, password string) error
- type Authenticator
- type ClientRecord
- type Config
- type MCPCallLog
- type SQLiteAuthenticator
- type Server
- func (s *Server) Authorize(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateUser(ctx context.Context, username, password string) error
- func (s *Server) DeleteToken(token string) error
- func (s *Server) DeleteUser(ctx context.Context, username string) error
- func (s *Server) GetToken(token string) (TokenRecord, bool, error)
- func (s *Server) InitSQLite(path string) error
- func (s *Server) IntrospectAccessToken(ctx context.Context, token string) (string, string, bool, error)
- func (s *Server) ListClients() ([]ClientRecord, error)
- func (s *Server) ListTokens() ([]TokenRecord, error)
- func (s *Server) ListUsers(ctx context.Context) ([]UserRecord, error)
- func (s *Server) LogMCPCall(entry MCPCallLog) error
- func (s *Server) Login(w http.ResponseWriter, r *http.Request)
- func (s *Server) PersistClient(id string, redirects []string) error
- func (s *Server) PersistToken(tr TokenRecord) error
- func (s *Server) Register(w http.ResponseWriter, r *http.Request)
- func (s *Server) Routes(mux *http.ServeMux)
- func (s *Server) RoutesASMetadata(w http.ResponseWriter, r *http.Request)
- func (s *Server) RoutesDiscovery(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetUserPassword(ctx context.Context, username, password string) error
- func (s *Server) Token(w http.ResponseWriter, r *http.Request)
- type StaticAuthenticator
- type TokenRecord
- type UserRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateUserInDB ¶
func DeleteTokenInDB ¶
func DeleteUserInDB ¶
func PersistClientInDB ¶
func PersistTokenInDB ¶
func PersistTokenInDB(dbPath string, tr TokenRecord) error
func SetUserPasswordInDB ¶
Types ¶
type Authenticator ¶
type Authenticator interface {
Authenticate(ctx context.Context, username, password string) (bool, error)
}
Authenticator provides a pluggable username/password verification hook. Implementations should return (true, nil) when the credentials are valid.
type ClientRecord ¶
func ListClientsInDB ¶
func ListClientsInDB(dbPath string) ([]ClientRecord, error)
type Config ¶
type Config struct {
Issuer string
DBPath string
EnableDevTokens bool
// Demo/static login credentials (optional; defaults used if empty when no other authenticator is configured)
User string
Pass string
// Optional pluggable authenticator; if nil, one is chosen based on DBPath or static User/Pass
Authenticator Authenticator
}
Config controls the embedded OIDC server behavior.
type MCPCallLog ¶
type MCPCallLog struct {
Timestamp time.Time
Subject string
ClientID string
RequestID string
ToolName string
ArgsJSON string
ResultJSON string
Status string
DurationMs int64
}
MCP tool call logging
type SQLiteAuthenticator ¶
type SQLiteAuthenticator struct {
DBPath string
}
SQLiteAuthenticator validates credentials against oauth_users table using bcrypt password hashes.
func (*SQLiteAuthenticator) Authenticate ¶
type Server ¶
type Server struct {
PrivateKey *rsa.PrivateKey
Issuer string
Provider fosite.OAuth2Provider
// demo login
User string
Pass string
// contains filtered or unexported fields
}
func (*Server) CreateUser ¶
func (*Server) DeleteToken ¶
DeleteToken removes a token from storage (when SQLite is enabled).
func (*Server) InitSQLite ¶
InitSQLite enables persistence of clients/keys/tokens to SQLite and loads existing clients on boot.
func (*Server) IntrospectAccessToken ¶
func (s *Server) IntrospectAccessToken(ctx context.Context, token string) (string, string, bool, error)
IntrospectAccessToken validates a bearer access token and returns subject and clientID when valid. If introspection fails and dev-tokens are enabled with DB persistence, falls back to DB tokens.
func (*Server) ListClients ¶
func (s *Server) ListClients() ([]ClientRecord, error)
ListClients returns clients from SQLite.
func (*Server) ListTokens ¶
func (s *Server) ListTokens() ([]TokenRecord, error)
func (*Server) LogMCPCall ¶
func (s *Server) LogMCPCall(entry MCPCallLog) error
func (*Server) PersistClient ¶
PersistClient stores/updates a client entry in SQLite.
func (*Server) PersistToken ¶
func (s *Server) PersistToken(tr TokenRecord) error
func (*Server) RoutesASMetadata ¶
func (s *Server) RoutesASMetadata(w http.ResponseWriter, r *http.Request)
func (*Server) RoutesDiscovery ¶
func (s *Server) RoutesDiscovery(w http.ResponseWriter, r *http.Request)
Small exported adapters retained for flexibility
func (*Server) SetUserPassword ¶
type StaticAuthenticator ¶
StaticAuthenticator validates against fixed credentials.
func (*StaticAuthenticator) Authenticate ¶
type TokenRecord ¶
type TokenRecord struct {
Token string
Subject string
ClientID string
Scopes []string
ExpiresAt time.Time
}
Token persistence helpers
func ListTokensInDB ¶
func ListTokensInDB(dbPath string) ([]TokenRecord, error)
type UserRecord ¶
Users persistence and management
func ListUsersInDB ¶
func ListUsersInDB(dbPath string) ([]UserRecord, error)