42wim/matterircd

Gitlab auth: can receive mattermost messages but it seems that my messages are not sent

Closed this issue · 11 comments

Hi,

I use matterircd to connect to a mattermost instance, and while I can receive the messages just fine, sending them does no appear to work.

Specifically, I am using:

  • matterircd-0.22.0-linux-64bit
  • When I connect it says INFO matterclient: Found version 5.28.0.5.28.1.848613061897d8430e1f14ee3cf20037.false
  • This mattermost instance is configured to use gitlab authentification and I cannot use a personal token. I connect using msg mattermost login mattermost.server MMAUTHTOKEN=
  • The shell where I launched matterircd throws errors saying [2021-01-12T15:34:25+01:00] ERROR matterclient: ChannelView update for token failed: : Invalid or expired session, please login again., or ERRO[2021-01-12T15:34:25+01:00] updateLastViewed failed: : Invalid or expired session, please login again.,

Thanks for matterircd!

Matthieu

42wim commented

can you run with --debug ?
Do you see "... with cookie (MMAUTH) token ..." somewhere?

42wim commented

I don't have such a setup so I can't test this myself, but it's strange that login succeeds and then the other stuff fails.

Can you ask the admin if they see something about this in the mattermost server logs?

My administrator gave me a personal token which solves the problem for me, but the problem remains.

@mlemerre so after you see all those "invalid or expired session" errors, can you log into the Mattermost web UI and type something? Does it come through to matterircd?

I'm just wonder if it's just that the session token has expired. Could probably reproduce this with:

curl -i -d '{"login_id":"someone@nowhere.com","password":"thisisabadpassword"}' http://localhost:8065/api/v4/users/login

Then grabbing the provided Token and using that with matterircd to connect.

I am having the same issue. I can receive messages that i type into the web client, but cannot send messages via matterircd. Here is a debug log. The message "this is a test" goes from browser client to matterircd and succeeds. The message "but i can't reply" fails to go from matterircd to the web client.

[2021-06-23T10:46:26+01:00] DEBUG matterclient: WsReceiver event: &model.WebSocketEvent{Event:"posted", Data:map[string]interface {}{"channel_display_name":"Off-Topic", "channel_name":"off-topic", "channel_type":"O", "post":"{\"id\":\"<id>\",\"create_at\":1624441586911,\"update_at\":1624441586911,\"edit_at\":0,\"delete_at\":0,\"is_pinned\":false,\"user_id\":\"<userid>\",\"channel_id\":\"<channelid>\",\"root_id\":\"\",\"parent_id\":\"\",\"original_id\":\"\",\"message\":\"This is a test :)\",\"type\":\"\",\"props\":{\"disable_group_highlight\":true},\"hashtags\":\"\",\"pending_post_id\":\"i3dfkdnju7rkjc94hr4ipdhqtc:1624441586749\",\"reply_count\":0,\"last_reply_at\":0,\"participants\":null,\"metadata\":{}}", "sender_name":"@<username>", "set_online":true, "team_id":"<team>"}, Broadcast:(*model.WebsocketBroadcast)(0xc000264740), Sequence:4, precomputedJSON:(*model.precomputedWebSocketEventJSON)(nil)}
DEBU[2021-06-23T10:46:26+01:00] MMUser WsReceiver: &model.WebSocketEvent{Event:"posted", Data:map[string]interface {}{"channel_display_name":"Off-Topic", "channel_name":"off-topic", "channel_type":"O", "post":"{\"id\":\"<id>\",\"create_at\":1624441586911,\"update_at\":1624441586911,\"edit_at\":0,\"delete_at\":0,\"is_pinned\":false,\"user_id\":\"<userid>\",\"channel_id\":\"<channelid>\",\"root_id\":\"\",\"parent_id\":\"\",\"original_id\":\"\",\"message\":\"This is a test :)\",\"type\":\"\",\"props\":{\"disable_group_highlight\":true},\"hashtags\":\"\",\"pending_post_id\":\"<id>:1624441586749\",\"reply_count\":0,\"last_reply_at\":0,\"participants\":null,\"metadata\":{}}", "sender_name":"@<username>", "set_online":true, "team_id":"<teamid>"}, Broadcast:(*model.WebsocketBroadcast)(0xc000264740), Sequence:4, precomputedJSON:(*model.precomputedWebSocketEventJSON)(nil)} 
DEBU[2021-06-23T10:46:26+01:00] handleWsActionPost() receiving userid <userid> 
DEBU[2021-06-23T10:46:26+01:00] handleWsActionPost() user <userid> sent This is a test :) 
DEBU[2021-06-23T10:46:26+01:00] &model.Post{Id:"<id>", CreateAt:1624441586911, UpdateAt:1624441586911, EditAt:0, DeleteAt:0, IsPinned:false, UserId:"<userid>", ChannelId:"<channelid>", RootId:"", ParentId:"", OriginalId:"", Message:"This is a test :)", MessageSource:"", Type:"", propsMu:sync.RWMutex{w:sync.Mutex{state:0, sema:0x0}, writerSem:0x0, readerSem:0x0, readerCount:0, readerWait:0}, Props:model.StringInterface{"disable_group_highlight":true}, Hashtags:"", Filenames:model.StringArray(nil), FileIds:model.StringArray(nil), PendingPostId:"<id>:1624441586749", HasReactions:false, ReplyCount:0, Metadata:(*model.PostMetadata)(0xc000176e00)} 
DEBU[2021-06-23T10:46:26+01:00] in handleWsMessage0                          
DEBU[2021-06-23T10:46:26+01:00] in handleChannelMessageEvent                  module=matterircd
DEBU[2021-06-23T10:46:26+01:00] -> :matt!matt@matt PRIVMSG #off-topic :This is a test :)  module=matterircd
[2021-06-23T10:46:26+01:00] DEBUG matterclient: WsReceiver event: &model.WebSocketEvent{Event:"channel_viewed", Data:map[string]interface {}{"channel_id":"<channelid>"}, Broadcast:(*model.WebsocketBroadcast)(0xc00054a340), Sequence:5, precomputedJSON:(*model.precomputedWebSocketEventJSON)(nil)}
DEBU[2021-06-23T10:46:26+01:00] MMUser WsReceiver: &model.WebSocketEvent{Event:"channel_viewed", Data:map[string]interface {}{"channel_id":"<channelid>"}, Broadcast:(*model.WebsocketBroadcast)(0xc00054a340), Sequence:5, precomputedJSON:(*model.precomputedWebSocketEventJSON)(nil)} 
DEBU[2021-06-23T10:46:27+01:00] in handleWsMessage0                          
[2021-06-23T10:46:29+01:00] DEBUG matterclient: posting lastview "<idthing>"
[2021-06-23T10:46:29+01:00] ERROR matterclient: ChannelView update for <idthing> failed: : Invalid or expired session, please login again., 
ERRO[2021-06-23T10:46:29+01:00] updateLastViewed failed: : Invalid or expired session, please login again.,  
DEBU[2021-06-23T10:46:47+01:00] B: "<- PRIVMSG #off-topic :But i can't reply"  module=matterircd
DEBU[2021-06-23T10:46:47+01:00] flushing buffer: &irc.Message{Prefix:(*irc.Prefix)(nil), Command:"PRIVMSG", Params:[]string{"#off-topic"}, Trailing:"But i can't reply", EmptyTrailing:false}  module=matterircd
DEBU[2021-06-23T10:46:47+01:00] -> :matt!matt@localhost PRIVMSG mattermost :msg: But i can't reply could not be send: : Invalid or expired session, please login again.,  module=matterircd
DEBU[2021-06-23T10:46:47+01:00] Executed &irc.Message{Prefix:(*irc.Prefix)(nil), Command:"PRIVMSG", Params:[]string{"#off-topic"}, Trailing:"But i can't reply", EmptyTrailing:false} &model.AppError{Id:"api.context.session_expired.app_error", Message:"Invalid or expired session, please login again.", DetailedError:"", RequestId:"<id>", StatusCode:401, Where:"", IsOAuth:false, params:map[string]interface {}(nil)}  module=matterircd
ERRO[2021-06-23T10:46:47+01:00] handler error for <id>: : Invalid or expired session, please login again.,   module=matterircd
[2021-06-23T10:46:47+01:00] DEBUG matterclient: WsReceiver response: &model.WebSocketResponse{Status:"OK", SeqReply:6, Data:map[string]interface {}{"node_id":"", "server_time":1.624441607866e+12, "text":"pong", "version":"5.34.0"}, Error:(*model.AppError)(nil)}
[2021-06-23T10:46:47+01:00] DEBUG matterclient: getting response: &model.WebSocketResponse{Status:"OK", SeqReply:6, Data:map[string]interface {}{"node_id":"", "server_time":1.624441607866e+12, "text":"pong", "version":"5.34.0"}, Error:(*model.AppError)(nil)}
[2021-06-23T10:46:48+01:00] DEBUG matterclient: WsReceiver event: &model.WebSocketEvent{Event:"channel_viewed", Data:map[string]interface {}{"channel_id":"frf8rkpxutn83yjd7jwahh6ifh"}, Broadcast:(*model.WebsocketBroadcast)(0xc000264300), Sequence:6, precomputedJSON:(*model.precomputedWebSocketEventJSON)(nil)}
DEBU[2021-06-23T10:46:48+01:00] MMUser WsReceiver: &model.WebSocketEvent{Event:"channel_viewed", Data:map[string]interface {}{"channel_id":"<channeid>"}, Broadcast:(*model.WebsocketBroadcast)(0xc000264300), Sequence:6, precomputedJSON:(*model.precomputedWebSocketEventJSON)(nil)} 

This is with version 0.22.0. It persists in 0.24.2 (5.34.0.5.34.2.9a2e430a5e80e46c9702deb3baeef177.true).

Ok, i fixed this for me. I was logging in with

/msg mattermost server team user MMAUTHTOKEN=<my mmauthtoken from cookies>

changing that to

/msg mattermost server team user token=<my mmauthtoken from cookies>

seems to have solved it.

42wim commented

I'm going to close this now then :)

The documentation on this could do with a quick update though (it says to use MMAUTHTOKEN): https://github.com/42wim/matterircd#mattermost-login-with-ssogitlab

42wim commented

@yourealwaysbe well it should be MMAUTHTOKEN, when using the token option you're using a "personal access token". I can add it as an extra "if it doesn't work try token="