Commit d71fd2f8 authored by Steven's avatar Steven

refactor: auth service

parent 9972a77d
...@@ -4,26 +4,40 @@ package memos.api.v1; ...@@ -4,26 +4,40 @@ package memos.api.v1;
import "api/v1/user_service.proto"; import "api/v1/user_service.proto";
import "google/api/annotations.proto"; import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.proto"; import "google/protobuf/empty.proto";
option go_package = "gen/api/v1"; option go_package = "gen/api/v1";
service AuthService { service AuthService {
// GetAuthStatus returns the current auth status of the user. // GetAuthStatus returns the current authentication status of the user.
// This method is idempotent and safe, suitable for checking authentication state.
rpc GetAuthStatus(GetAuthStatusRequest) returns (User) { rpc GetAuthStatus(GetAuthStatusRequest) returns (User) {
option (google.api.http) = {post: "/api/v1/auth/status"}; option (google.api.http) = {get: "/api/v1/auth/status"};
} }
// SignIn signs in the user.
rpc SignIn(SignInRequest) returns (User) { // CreateSession authenticates a user and creates a new session.
option (google.api.http) = {post: "/api/v1/auth/signin"}; // Returns the authenticated user information upon successful authentication.
rpc CreateSession(CreateSessionRequest) returns (User) {
option (google.api.http) = {
post: "/api/v1/auth/sessions"
body: "*"
};
} }
// SignUp signs up the user with the given username and password.
rpc SignUp(SignUpRequest) returns (User) { // RegisterUser creates a new user account with username and password.
option (google.api.http) = {post: "/api/v1/auth/signup"}; // Returns the newly created user information upon successful registration.
rpc RegisterUser(RegisterUserRequest) returns (User) {
option (google.api.http) = {
post: "/api/v1/auth/users"
body: "*"
};
} }
// SignOut signs out the user.
rpc SignOut(SignOutRequest) returns (google.protobuf.Empty) { // DeleteSession terminates the current user session.
option (google.api.http) = {post: "/api/v1/auth/signout"}; // This is an idempotent operation that invalidates the user's authentication.
rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v1/auth/sessions/current"};
} }
} }
...@@ -33,8 +47,9 @@ message GetAuthStatusResponse { ...@@ -33,8 +47,9 @@ message GetAuthStatusResponse {
User user = 1; User user = 1;
} }
message SignInRequest { message CreateSessionRequest {
// Provide one authentication method (username/password or SSO). // Provide one authentication method (username/password or SSO).
// Required field to specify the authentication method.
oneof method { oneof method {
// Username and password authentication method. // Username and password authentication method.
PasswordCredentials password_credentials = 1; PasswordCredentials password_credentials = 1;
...@@ -42,31 +57,44 @@ message SignInRequest { ...@@ -42,31 +57,44 @@ message SignInRequest {
// SSO provider authentication method. // SSO provider authentication method.
SSOCredentials sso_credentials = 2; SSOCredentials sso_credentials = 2;
} }
// Whether the session should never expire. // Whether the session should never expire.
bool never_expire = 3; // Optional field that defaults to false for security.
bool never_expire = 3 [(google.api.field_behavior) = OPTIONAL];
} }
message PasswordCredentials { message PasswordCredentials {
// The username to sign in with. // The username to sign in with.
string username = 1; // Required field for password-based authentication.
string username = 1 [(google.api.field_behavior) = REQUIRED];
// The password to sign in with. // The password to sign in with.
string password = 2; // Required field for password-based authentication.
string password = 2 [(google.api.field_behavior) = REQUIRED];
} }
message SSOCredentials { message SSOCredentials {
// The ID of the SSO provider. // The ID of the SSO provider.
int32 idp_id = 1; // Required field to identify the SSO provider.
// The code to sign in with. int32 idp_id = 1 [(google.api.field_behavior) = REQUIRED];
string code = 2;
// The redirect URI. // The authorization code from the SSO provider.
string redirect_uri = 3; // Required field for completing the SSO flow.
string code = 2 [(google.api.field_behavior) = REQUIRED];
// The redirect URI used in the SSO flow.
// Required field for security validation.
string redirect_uri = 3 [(google.api.field_behavior) = REQUIRED];
} }
message SignUpRequest { message RegisterUserRequest {
// The username to sign up with. // The username to sign up with.
string username = 1; // Required field that must be unique across the system.
string username = 1 [(google.api.field_behavior) = REQUIRED];
// The password to sign up with. // The password to sign up with.
string password = 2; // Required field that should meet security requirements.
string password = 2 [(google.api.field_behavior) = REQUIRED];
} }
message SignOutRequest {} message DeleteSessionRequest {}
...@@ -3,68 +3,88 @@ syntax = "proto3"; ...@@ -3,68 +3,88 @@ syntax = "proto3";
package memos.api.v1; package memos.api.v1;
import "google/api/annotations.proto"; import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
option go_package = "gen/api/v1"; option go_package = "gen/api/v1";
service MarkdownService { service MarkdownService {
// ParseMarkdown parses the given markdown content and returns a list of nodes. // ParseMarkdown parses the given markdown content and returns a list of nodes.
// This is a utility method that transforms markdown text into structured nodes.
rpc ParseMarkdown(ParseMarkdownRequest) returns (ParseMarkdownResponse) { rpc ParseMarkdown(ParseMarkdownRequest) returns (ParseMarkdownResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/markdown:parse" post: "/api/v1/markdown:parse"
body: "*" body: "*"
}; };
} }
// RestoreMarkdownNodes restores the given nodes to markdown content. // RestoreMarkdownNodes restores the given nodes to markdown content.
// This is the inverse operation of ParseMarkdown.
rpc RestoreMarkdownNodes(RestoreMarkdownNodesRequest) returns (RestoreMarkdownNodesResponse) { rpc RestoreMarkdownNodes(RestoreMarkdownNodesRequest) returns (RestoreMarkdownNodesResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/markdown/node:restore" post: "/api/v1/markdown:restore"
body: "*" body: "*"
}; };
} }
// StringifyMarkdownNodes stringify the given nodes to plain text content. // StringifyMarkdownNodes stringify the given nodes to plain text content.
// This removes all markdown formatting and returns plain text.
rpc StringifyMarkdownNodes(StringifyMarkdownNodesRequest) returns (StringifyMarkdownNodesResponse) { rpc StringifyMarkdownNodes(StringifyMarkdownNodesRequest) returns (StringifyMarkdownNodesResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/markdown/node:stringify" post: "/api/v1/markdown:stringify"
body: "*" body: "*"
}; };
} }
// GetLinkMetadata returns metadata for a given link. // GetLinkMetadata returns metadata for a given link.
// This is useful for generating link previews.
rpc GetLinkMetadata(GetLinkMetadataRequest) returns (LinkMetadata) { rpc GetLinkMetadata(GetLinkMetadataRequest) returns (LinkMetadata) {
option (google.api.http) = {get: "/api/v1/markdown/link:metadata"}; option (google.api.http) = {get: "/api/v1/markdown/links:getMetadata"};
} }
} }
message ParseMarkdownRequest { message ParseMarkdownRequest {
string markdown = 1; // The markdown content to parse.
string markdown = 1 [(google.api.field_behavior) = REQUIRED];
} }
message ParseMarkdownResponse { message ParseMarkdownResponse {
// The parsed markdown nodes.
repeated Node nodes = 1; repeated Node nodes = 1;
} }
message RestoreMarkdownNodesRequest { message RestoreMarkdownNodesRequest {
repeated Node nodes = 1; // The nodes to restore to markdown content.
repeated Node nodes = 1 [(google.api.field_behavior) = REQUIRED];
} }
message RestoreMarkdownNodesResponse { message RestoreMarkdownNodesResponse {
// The restored markdown content.
string markdown = 1; string markdown = 1;
} }
message StringifyMarkdownNodesRequest { message StringifyMarkdownNodesRequest {
repeated Node nodes = 1; // The nodes to stringify to plain text.
repeated Node nodes = 1 [(google.api.field_behavior) = REQUIRED];
} }
message StringifyMarkdownNodesResponse { message StringifyMarkdownNodesResponse {
// The plain text content.
string plain_text = 1; string plain_text = 1;
} }
message GetLinkMetadataRequest { message GetLinkMetadataRequest {
string link = 1; // The link URL to get metadata for.
string link = 1 [(google.api.field_behavior) = REQUIRED];
} }
message LinkMetadata { message LinkMetadata {
// The title of the linked page.
string title = 1; string title = 1;
// The description of the linked page.
string description = 2; string description = 2;
// The URL of the preview image for the linked page.
string image = 3; string image = 3;
} }
...@@ -218,7 +238,10 @@ message TableNode { ...@@ -218,7 +238,10 @@ message TableNode {
} }
message EmbeddedContentNode { message EmbeddedContentNode {
// The resource name of the embedded content.
string resource_name = 1; string resource_name = 1;
// Additional parameters for the embedded content.
string params = 2; string params = 2;
} }
...@@ -289,7 +312,10 @@ message SuperscriptNode { ...@@ -289,7 +312,10 @@ message SuperscriptNode {
} }
message ReferencedContentNode { message ReferencedContentNode {
// The resource name of the referenced content.
string resource_name = 1; string resource_name = 1;
// Additional parameters for the referenced content.
string params = 2; string params = 2;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -172,7 +172,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv ...@@ -172,7 +172,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:restore")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown:restore"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -192,7 +192,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv ...@@ -192,7 +192,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:stringify")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown:stringify"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -212,7 +212,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv ...@@ -212,7 +212,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/link:metadata")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/links:getMetadata"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -287,7 +287,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv ...@@ -287,7 +287,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:restore")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown:restore"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -304,7 +304,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv ...@@ -304,7 +304,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:stringify")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown:stringify"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -321,7 +321,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv ...@@ -321,7 +321,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/link:metadata")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/links:getMetadata"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -339,9 +339,9 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv ...@@ -339,9 +339,9 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv
var ( var (
pattern_MarkdownService_ParseMarkdown_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "parse")) pattern_MarkdownService_ParseMarkdown_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "parse"))
pattern_MarkdownService_RestoreMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "node"}, "restore")) pattern_MarkdownService_RestoreMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "restore"))
pattern_MarkdownService_StringifyMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "node"}, "stringify")) pattern_MarkdownService_StringifyMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "stringify"))
pattern_MarkdownService_GetLinkMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "link"}, "metadata")) pattern_MarkdownService_GetLinkMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "links"}, "getMetadata"))
) )
var ( var (
......
...@@ -30,12 +30,16 @@ const ( ...@@ -30,12 +30,16 @@ const (
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type MarkdownServiceClient interface { type MarkdownServiceClient interface {
// ParseMarkdown parses the given markdown content and returns a list of nodes. // ParseMarkdown parses the given markdown content and returns a list of nodes.
// This is a utility method that transforms markdown text into structured nodes.
ParseMarkdown(ctx context.Context, in *ParseMarkdownRequest, opts ...grpc.CallOption) (*ParseMarkdownResponse, error) ParseMarkdown(ctx context.Context, in *ParseMarkdownRequest, opts ...grpc.CallOption) (*ParseMarkdownResponse, error)
// RestoreMarkdownNodes restores the given nodes to markdown content. // RestoreMarkdownNodes restores the given nodes to markdown content.
// This is the inverse operation of ParseMarkdown.
RestoreMarkdownNodes(ctx context.Context, in *RestoreMarkdownNodesRequest, opts ...grpc.CallOption) (*RestoreMarkdownNodesResponse, error) RestoreMarkdownNodes(ctx context.Context, in *RestoreMarkdownNodesRequest, opts ...grpc.CallOption) (*RestoreMarkdownNodesResponse, error)
// StringifyMarkdownNodes stringify the given nodes to plain text content. // StringifyMarkdownNodes stringify the given nodes to plain text content.
// This removes all markdown formatting and returns plain text.
StringifyMarkdownNodes(ctx context.Context, in *StringifyMarkdownNodesRequest, opts ...grpc.CallOption) (*StringifyMarkdownNodesResponse, error) StringifyMarkdownNodes(ctx context.Context, in *StringifyMarkdownNodesRequest, opts ...grpc.CallOption) (*StringifyMarkdownNodesResponse, error)
// GetLinkMetadata returns metadata for a given link. // GetLinkMetadata returns metadata for a given link.
// This is useful for generating link previews.
GetLinkMetadata(ctx context.Context, in *GetLinkMetadataRequest, opts ...grpc.CallOption) (*LinkMetadata, error) GetLinkMetadata(ctx context.Context, in *GetLinkMetadataRequest, opts ...grpc.CallOption) (*LinkMetadata, error)
} }
...@@ -92,12 +96,16 @@ func (c *markdownServiceClient) GetLinkMetadata(ctx context.Context, in *GetLink ...@@ -92,12 +96,16 @@ func (c *markdownServiceClient) GetLinkMetadata(ctx context.Context, in *GetLink
// for forward compatibility. // for forward compatibility.
type MarkdownServiceServer interface { type MarkdownServiceServer interface {
// ParseMarkdown parses the given markdown content and returns a list of nodes. // ParseMarkdown parses the given markdown content and returns a list of nodes.
// This is a utility method that transforms markdown text into structured nodes.
ParseMarkdown(context.Context, *ParseMarkdownRequest) (*ParseMarkdownResponse, error) ParseMarkdown(context.Context, *ParseMarkdownRequest) (*ParseMarkdownResponse, error)
// RestoreMarkdownNodes restores the given nodes to markdown content. // RestoreMarkdownNodes restores the given nodes to markdown content.
// This is the inverse operation of ParseMarkdown.
RestoreMarkdownNodes(context.Context, *RestoreMarkdownNodesRequest) (*RestoreMarkdownNodesResponse, error) RestoreMarkdownNodes(context.Context, *RestoreMarkdownNodesRequest) (*RestoreMarkdownNodesResponse, error)
// StringifyMarkdownNodes stringify the given nodes to plain text content. // StringifyMarkdownNodes stringify the given nodes to plain text content.
// This removes all markdown formatting and returns plain text.
StringifyMarkdownNodes(context.Context, *StringifyMarkdownNodesRequest) (*StringifyMarkdownNodesResponse, error) StringifyMarkdownNodes(context.Context, *StringifyMarkdownNodesRequest) (*StringifyMarkdownNodesResponse, error)
// GetLinkMetadata returns metadata for a given link. // GetLinkMetadata returns metadata for a given link.
// This is useful for generating link previews.
GetLinkMetadata(context.Context, *GetLinkMetadataRequest) (*LinkMetadata, error) GetLinkMetadata(context.Context, *GetLinkMetadataRequest) (*LinkMetadata, error)
mustEmbedUnimplementedMarkdownServiceServer() mustEmbedUnimplementedMarkdownServiceServer()
} }
......
This diff is collapsed.
...@@ -6,10 +6,9 @@ var authenticationAllowlistMethods = map[string]bool{ ...@@ -6,10 +6,9 @@ var authenticationAllowlistMethods = map[string]bool{
"/memos.api.v1.IdentityProviderService/GetIdentityProvider": true, "/memos.api.v1.IdentityProviderService/GetIdentityProvider": true,
"/memos.api.v1.IdentityProviderService/ListIdentityProviders": true, "/memos.api.v1.IdentityProviderService/ListIdentityProviders": true,
"/memos.api.v1.AuthService/GetAuthStatus": true, "/memos.api.v1.AuthService/GetAuthStatus": true,
"/memos.api.v1.AuthService/SignIn": true, "/memos.api.v1.AuthService/CreateSession": true,
"/memos.api.v1.AuthService/SignInWithSSO": true, "/memos.api.v1.AuthService/RegisterUser": true,
"/memos.api.v1.AuthService/SignOut": true, "/memos.api.v1.AuthService/DeleteSession": true,
"/memos.api.v1.AuthService/SignUp": true,
"/memos.api.v1.UserService/GetUser": true, "/memos.api.v1.UserService/GetUser": true,
"/memos.api.v1.UserService/GetUserAvatar": true, "/memos.api.v1.UserService/GetUserAvatar": true,
"/memos.api.v1.UserService/GetUserStats": true, "/memos.api.v1.UserService/GetUserStats": true,
......
...@@ -44,7 +44,7 @@ func (s *APIV1Service) GetAuthStatus(ctx context.Context, _ *v1pb.GetAuthStatusR ...@@ -44,7 +44,7 @@ func (s *APIV1Service) GetAuthStatus(ctx context.Context, _ *v1pb.GetAuthStatusR
return convertUserFromStore(user), nil return convertUserFromStore(user), nil
} }
func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest) (*v1pb.User, error) { func (s *APIV1Service) CreateSession(ctx context.Context, request *v1pb.CreateSessionRequest) (*v1pb.User, error) {
var existingUser *store.User var existingUser *store.User
if passwordCredentials := request.GetPasswordCredentials(); passwordCredentials != nil { if passwordCredentials := request.GetPasswordCredentials(); passwordCredentials != nil {
user, err := s.Store.GetUser(ctx, &store.FindUser{ user, err := s.Store.GetUser(ctx, &store.FindUser{
...@@ -189,7 +189,7 @@ func (s *APIV1Service) doSignIn(ctx context.Context, user *store.User, expireTim ...@@ -189,7 +189,7 @@ func (s *APIV1Service) doSignIn(ctx context.Context, user *store.User, expireTim
return nil return nil
} }
func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest) (*v1pb.User, error) { func (s *APIV1Service) RegisterUser(ctx context.Context, request *v1pb.RegisterUserRequest) (*v1pb.User, error) {
workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx) workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get workspace general setting, error: %v", err) return nil, status.Errorf(codes.Internal, "failed to get workspace general setting, error: %v", err)
...@@ -237,7 +237,7 @@ func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest) ...@@ -237,7 +237,7 @@ func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest)
return convertUserFromStore(user), nil return convertUserFromStore(user), nil
} }
func (s *APIV1Service) SignOut(ctx context.Context, _ *v1pb.SignOutRequest) (*emptypb.Empty, error) { func (s *APIV1Service) DeleteSession(ctx context.Context, _ *v1pb.DeleteSessionRequest) (*emptypb.Empty, error) {
accessToken, ok := ctx.Value(accessTokenContextKey).(string) accessToken, ok := ctx.Value(accessTokenContextKey).(string)
// Try to delete the access token from the store. // Try to delete the access token from the store.
if ok { if ok {
......
...@@ -45,7 +45,7 @@ const PasswordSignInForm = observer(() => { ...@@ -45,7 +45,7 @@ const PasswordSignInForm = observer(() => {
try { try {
actionBtnLoadingState.setLoading(); actionBtnLoadingState.setLoading();
await authServiceClient.signIn({ passwordCredentials: { username, password }, neverExpire: remember }); await authServiceClient.createSession({ passwordCredentials: { username, password }, neverExpire: remember });
await initialUserStore(); await initialUserStore();
navigateTo("/"); navigateTo("/");
} catch (error: any) { } catch (error: any) {
......
...@@ -19,7 +19,7 @@ const UserBanner = (props: Props) => { ...@@ -19,7 +19,7 @@ const UserBanner = (props: Props) => {
const currentUser = useCurrentUser(); const currentUser = useCurrentUser();
const handleSignOut = async () => { const handleSignOut = async () => {
await authServiceClient.signOut({}); await authServiceClient.deleteSession({});
window.location.href = Routes.AUTH; window.location.href = Routes.AUTH;
}; };
......
...@@ -46,7 +46,7 @@ const AuthCallback = observer(() => { ...@@ -46,7 +46,7 @@ const AuthCallback = observer(() => {
const redirectUri = absolutifyLink("/auth/callback"); const redirectUri = absolutifyLink("/auth/callback");
(async () => { (async () => {
try { try {
await authServiceClient.signIn({ await authServiceClient.createSession({
ssoCredentials: { ssoCredentials: {
idpId: identityProviderId, idpId: identityProviderId,
code, code,
......
...@@ -47,7 +47,7 @@ const SignUp = observer(() => { ...@@ -47,7 +47,7 @@ const SignUp = observer(() => {
try { try {
actionBtnLoadingState.setLoading(); actionBtnLoadingState.setLoading();
await authServiceClient.signUp({ username, password }); await authServiceClient.registerUser({ username, password });
await initialUserStore(); await initialUserStore();
navigateTo("/"); navigateTo("/");
} catch (error: any) { } catch (error: any) {
......
This diff is collapsed.
...@@ -225,36 +225,46 @@ export function nodeTypeToNumber(object: NodeType): number { ...@@ -225,36 +225,46 @@ export function nodeTypeToNumber(object: NodeType): number {
} }
export interface ParseMarkdownRequest { export interface ParseMarkdownRequest {
/** The markdown content to parse. */
markdown: string; markdown: string;
} }
export interface ParseMarkdownResponse { export interface ParseMarkdownResponse {
/** The parsed markdown nodes. */
nodes: Node[]; nodes: Node[];
} }
export interface RestoreMarkdownNodesRequest { export interface RestoreMarkdownNodesRequest {
/** The nodes to restore to markdown content. */
nodes: Node[]; nodes: Node[];
} }
export interface RestoreMarkdownNodesResponse { export interface RestoreMarkdownNodesResponse {
/** The restored markdown content. */
markdown: string; markdown: string;
} }
export interface StringifyMarkdownNodesRequest { export interface StringifyMarkdownNodesRequest {
/** The nodes to stringify to plain text. */
nodes: Node[]; nodes: Node[];
} }
export interface StringifyMarkdownNodesResponse { export interface StringifyMarkdownNodesResponse {
/** The plain text content. */
plainText: string; plainText: string;
} }
export interface GetLinkMetadataRequest { export interface GetLinkMetadataRequest {
/** The link URL to get metadata for. */
link: string; link: string;
} }
export interface LinkMetadata { export interface LinkMetadata {
/** The title of the linked page. */
title: string; title: string;
/** The description of the linked page. */
description: string; description: string;
/** The URL of the preview image for the linked page. */
image: string; image: string;
} }
...@@ -407,7 +417,9 @@ export interface TableNode_Row { ...@@ -407,7 +417,9 @@ export interface TableNode_Row {
} }
export interface EmbeddedContentNode { export interface EmbeddedContentNode {
/** The resource name of the embedded content. */
resourceName: string; resourceName: string;
/** Additional parameters for the embedded content. */
params: string; params: string;
} }
...@@ -478,7 +490,9 @@ export interface SuperscriptNode { ...@@ -478,7 +490,9 @@ export interface SuperscriptNode {
} }
export interface ReferencedContentNode { export interface ReferencedContentNode {
/** The resource name of the referenced content. */
resourceName: string; resourceName: string;
/** Additional parameters for the referenced content. */
params: string; params: string;
} }
...@@ -3202,7 +3216,10 @@ export const MarkdownServiceDefinition = { ...@@ -3202,7 +3216,10 @@ export const MarkdownServiceDefinition = {
name: "MarkdownService", name: "MarkdownService",
fullName: "memos.api.v1.MarkdownService", fullName: "memos.api.v1.MarkdownService",
methods: { methods: {
/** ParseMarkdown parses the given markdown content and returns a list of nodes. */ /**
* ParseMarkdown parses the given markdown content and returns a list of nodes.
* This is a utility method that transforms markdown text into structured nodes.
*/
parseMarkdown: { parseMarkdown: {
name: "ParseMarkdown", name: "ParseMarkdown",
requestType: ParseMarkdownRequest, requestType: ParseMarkdownRequest,
...@@ -3246,7 +3263,10 @@ export const MarkdownServiceDefinition = { ...@@ -3246,7 +3263,10 @@ export const MarkdownServiceDefinition = {
}, },
}, },
}, },
/** RestoreMarkdownNodes restores the given nodes to markdown content. */ /**
* RestoreMarkdownNodes restores the given nodes to markdown content.
* This is the inverse operation of ParseMarkdown.
*/
restoreMarkdownNodes: { restoreMarkdownNodes: {
name: "RestoreMarkdownNodes", name: "RestoreMarkdownNodes",
requestType: RestoreMarkdownNodesRequest, requestType: RestoreMarkdownNodesRequest,
...@@ -3257,12 +3277,12 @@ export const MarkdownServiceDefinition = { ...@@ -3257,12 +3277,12 @@ export const MarkdownServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
34, 29,
58, 58,
1, 1,
42, 42,
34, 34,
29, 24,
47, 47,
97, 97,
112, 112,
...@@ -3279,11 +3299,6 @@ export const MarkdownServiceDefinition = { ...@@ -3279,11 +3299,6 @@ export const MarkdownServiceDefinition = {
111, 111,
119, 119,
110, 110,
47,
110,
111,
100,
101,
58, 58,
114, 114,
101, 101,
...@@ -3297,7 +3312,10 @@ export const MarkdownServiceDefinition = { ...@@ -3297,7 +3312,10 @@ export const MarkdownServiceDefinition = {
}, },
}, },
}, },
/** StringifyMarkdownNodes stringify the given nodes to plain text content. */ /**
* StringifyMarkdownNodes stringify the given nodes to plain text content.
* This removes all markdown formatting and returns plain text.
*/
stringifyMarkdownNodes: { stringifyMarkdownNodes: {
name: "StringifyMarkdownNodes", name: "StringifyMarkdownNodes",
requestType: StringifyMarkdownNodesRequest, requestType: StringifyMarkdownNodesRequest,
...@@ -3308,12 +3326,12 @@ export const MarkdownServiceDefinition = { ...@@ -3308,12 +3326,12 @@ export const MarkdownServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
36, 31,
58, 58,
1, 1,
42, 42,
34, 34,
31, 26,
47, 47,
97, 97,
112, 112,
...@@ -3330,11 +3348,6 @@ export const MarkdownServiceDefinition = { ...@@ -3330,11 +3348,6 @@ export const MarkdownServiceDefinition = {
111, 111,
119, 119,
110, 110,
47,
110,
111,
100,
101,
58, 58,
115, 115,
116, 116,
...@@ -3350,7 +3363,10 @@ export const MarkdownServiceDefinition = { ...@@ -3350,7 +3363,10 @@ export const MarkdownServiceDefinition = {
}, },
}, },
}, },
/** GetLinkMetadata returns metadata for a given link. */ /**
* GetLinkMetadata returns metadata for a given link.
* This is useful for generating link previews.
*/
getLinkMetadata: { getLinkMetadata: {
name: "GetLinkMetadata", name: "GetLinkMetadata",
requestType: GetLinkMetadataRequest, requestType: GetLinkMetadataRequest,
...@@ -3361,9 +3377,9 @@ export const MarkdownServiceDefinition = { ...@@ -3361,9 +3377,9 @@ export const MarkdownServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
32, 36,
18, 18,
30, 34,
47, 47,
97, 97,
112, 112,
...@@ -3385,8 +3401,12 @@ export const MarkdownServiceDefinition = { ...@@ -3385,8 +3401,12 @@ export const MarkdownServiceDefinition = {
105, 105,
110, 110,
107, 107,
115,
58, 58,
109, 103,
101,
116,
77,
101, 101,
116, 116,
97, 97,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment