Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/auth_service.proto
package apiconnect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
api "github.com/usememos/memos/proto/gen/api"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// AuthServiceName is the fully-qualified name of the AuthService service.
AuthServiceName = "memos.api.AuthService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// AuthServiceSignInProcedure is the fully-qualified name of the AuthService's SignIn RPC.
AuthServiceSignInProcedure = "/memos.api.AuthService/SignIn"
// AuthServiceRefreshTokenProcedure is the fully-qualified name of the AuthService's RefreshToken
// RPC.
AuthServiceRefreshTokenProcedure = "/memos.api.AuthService/RefreshToken"
// AuthServiceGetCurrentUserProcedure is the fully-qualified name of the AuthService's
// GetCurrentUser RPC.
AuthServiceGetCurrentUserProcedure = "/memos.api.AuthService/GetCurrentUser"
// AuthServiceSignOutProcedure is the fully-qualified name of the AuthService's SignOut RPC.
AuthServiceSignOutProcedure = "/memos.api.AuthService/SignOut"
)
// AuthServiceClient is a client for the memos.api.AuthService service.
type AuthServiceClient interface {
// SignIn authenticates a user with password or SSO credentials.
// On success, returns a short-lived access token and sets a refresh token in an HttpOnly cookie.
// Public. Attempts are rate limited. Archived users cannot sign in.
SignIn(context.Context, *connect.Request[api.SignInRequest]) (*connect.Response[api.SignInResponse], error)
// RefreshToken exchanges the refresh token for a new access token.
// The refresh token is read from the HttpOnly cookie and rotated: the old token is revoked and a new one with a
// fresh 30-day expiry is set in the cookie.
// Public, so it can be called after the access token has expired.
RefreshToken(context.Context, *connect.Request[api.RefreshTokenRequest]) (*connect.Response[api.RefreshTokenResponse], error)
// GetCurrentUser returns the authenticated user, similar to OIDC's /userinfo endpoint.
// When the caller is not signed in or the account is no longer active, clears the refresh token cookie and returns
// UNAUTHENTICATED.
GetCurrentUser(context.Context, *connect.Request[api.GetCurrentUserRequest]) (*connect.Response[api.GetCurrentUserResponse], error)
// SignOut ends the current session.
// Revokes the refresh token from the cookie and clears the cookie.
SignOut(context.Context, *connect.Request[api.SignOutRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewAuthServiceClient constructs a client for the memos.api.AuthService service. By default, it
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
// connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewAuthServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AuthServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
authServiceMethods := api.File_api_auth_service_proto.Services().ByName("AuthService").Methods()
return &authServiceClient{
signIn: connect.NewClient[api.SignInRequest, api.SignInResponse](
httpClient,
baseURL+AuthServiceSignInProcedure,
connect.WithSchema(authServiceMethods.ByName("SignIn")),
connect.WithClientOptions(opts...),
),
refreshToken: connect.NewClient[api.RefreshTokenRequest, api.RefreshTokenResponse](
httpClient,
baseURL+AuthServiceRefreshTokenProcedure,
connect.WithSchema(authServiceMethods.ByName("RefreshToken")),
connect.WithClientOptions(opts...),
),
getCurrentUser: connect.NewClient[api.GetCurrentUserRequest, api.GetCurrentUserResponse](
httpClient,
baseURL+AuthServiceGetCurrentUserProcedure,
connect.WithSchema(authServiceMethods.ByName("GetCurrentUser")),
connect.WithClientOptions(opts...),
),
signOut: connect.NewClient[api.SignOutRequest, emptypb.Empty](
httpClient,
baseURL+AuthServiceSignOutProcedure,
connect.WithSchema(authServiceMethods.ByName("SignOut")),
connect.WithClientOptions(opts...),
),
}
}
// authServiceClient implements AuthServiceClient.
type authServiceClient struct {
signIn *connect.Client[api.SignInRequest, api.SignInResponse]
refreshToken *connect.Client[api.RefreshTokenRequest, api.RefreshTokenResponse]
getCurrentUser *connect.Client[api.GetCurrentUserRequest, api.GetCurrentUserResponse]
signOut *connect.Client[api.SignOutRequest, emptypb.Empty]
}
// SignIn calls memos.api.AuthService.SignIn.
func (c *authServiceClient) SignIn(ctx context.Context, req *connect.Request[api.SignInRequest]) (*connect.Response[api.SignInResponse], error) {
return c.signIn.CallUnary(ctx, req)
}
// RefreshToken calls memos.api.AuthService.RefreshToken.
func (c *authServiceClient) RefreshToken(ctx context.Context, req *connect.Request[api.RefreshTokenRequest]) (*connect.Response[api.RefreshTokenResponse], error) {
return c.refreshToken.CallUnary(ctx, req)
}
// GetCurrentUser calls memos.api.AuthService.GetCurrentUser.
func (c *authServiceClient) GetCurrentUser(ctx context.Context, req *connect.Request[api.GetCurrentUserRequest]) (*connect.Response[api.GetCurrentUserResponse], error) {
return c.getCurrentUser.CallUnary(ctx, req)
}
// SignOut calls memos.api.AuthService.SignOut.
func (c *authServiceClient) SignOut(ctx context.Context, req *connect.Request[api.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
return c.signOut.CallUnary(ctx, req)
}
// AuthServiceHandler is an implementation of the memos.api.AuthService service.
type AuthServiceHandler interface {
// SignIn authenticates a user with password or SSO credentials.
// On success, returns a short-lived access token and sets a refresh token in an HttpOnly cookie.
// Public. Attempts are rate limited. Archived users cannot sign in.
SignIn(context.Context, *connect.Request[api.SignInRequest]) (*connect.Response[api.SignInResponse], error)
// RefreshToken exchanges the refresh token for a new access token.
// The refresh token is read from the HttpOnly cookie and rotated: the old token is revoked and a new one with a
// fresh 30-day expiry is set in the cookie.
// Public, so it can be called after the access token has expired.
RefreshToken(context.Context, *connect.Request[api.RefreshTokenRequest]) (*connect.Response[api.RefreshTokenResponse], error)
// GetCurrentUser returns the authenticated user, similar to OIDC's /userinfo endpoint.
// When the caller is not signed in or the account is no longer active, clears the refresh token cookie and returns
// UNAUTHENTICATED.
GetCurrentUser(context.Context, *connect.Request[api.GetCurrentUserRequest]) (*connect.Response[api.GetCurrentUserResponse], error)
// SignOut ends the current session.
// Revokes the refresh token from the cookie and clears the cookie.
SignOut(context.Context, *connect.Request[api.SignOutRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewAuthServiceHandler builds an HTTP handler from the service implementation. It returns the path
// on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewAuthServiceHandler(svc AuthServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
authServiceMethods := api.File_api_auth_service_proto.Services().ByName("AuthService").Methods()
authServiceSignInHandler := connect.NewUnaryHandler(
AuthServiceSignInProcedure,
svc.SignIn,
connect.WithSchema(authServiceMethods.ByName("SignIn")),
connect.WithHandlerOptions(opts...),
)
authServiceRefreshTokenHandler := connect.NewUnaryHandler(
AuthServiceRefreshTokenProcedure,
svc.RefreshToken,
connect.WithSchema(authServiceMethods.ByName("RefreshToken")),
connect.WithHandlerOptions(opts...),
)
authServiceGetCurrentUserHandler := connect.NewUnaryHandler(
AuthServiceGetCurrentUserProcedure,
svc.GetCurrentUser,
connect.WithSchema(authServiceMethods.ByName("GetCurrentUser")),
connect.WithHandlerOptions(opts...),
)
authServiceSignOutHandler := connect.NewUnaryHandler(
AuthServiceSignOutProcedure,
svc.SignOut,
connect.WithSchema(authServiceMethods.ByName("SignOut")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.AuthService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case AuthServiceSignInProcedure:
authServiceSignInHandler.ServeHTTP(w, r)
case AuthServiceRefreshTokenProcedure:
authServiceRefreshTokenHandler.ServeHTTP(w, r)
case AuthServiceGetCurrentUserProcedure:
authServiceGetCurrentUserHandler.ServeHTTP(w, r)
case AuthServiceSignOutProcedure:
authServiceSignOutHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedAuthServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedAuthServiceHandler struct{}
func (UnimplementedAuthServiceHandler) SignIn(context.Context, *connect.Request[api.SignInRequest]) (*connect.Response[api.SignInResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AuthService.SignIn is not implemented"))
}
func (UnimplementedAuthServiceHandler) RefreshToken(context.Context, *connect.Request[api.RefreshTokenRequest]) (*connect.Response[api.RefreshTokenResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AuthService.RefreshToken is not implemented"))
}
func (UnimplementedAuthServiceHandler) GetCurrentUser(context.Context, *connect.Request[api.GetCurrentUserRequest]) (*connect.Response[api.GetCurrentUserResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AuthService.GetCurrentUser is not implemented"))
}
func (UnimplementedAuthServiceHandler) SignOut(context.Context, *connect.Request[api.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AuthService.SignOut is not implemented"))
}