apprise icon indicating copy to clipboard operation
apprise copied to clipboard

Matrix Token (m.login.token) support added

Open caronc opened this issue 1 year ago • 5 comments

Description:

Related issue (if applicable): #895

The URLs now trigger reference to the Matrix Token based Authentication (m.login.token):

  • {schema}://{token}@{host}/{targets}
  • {schema}://{token}@{host}:{port}/{targets}

Checklist

  • [ ] The code change is tested and works locally.
  • [x] There is no commented out code in this PR.
  • [x] No lint errors (use flake8)
  • [x] 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@895-matrix-token-support

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  "matrixs://token@host/#general"

caronc avatar Sep 14 '24 21:09 caronc

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.29%. Comparing base (f37dfbf) to head (05b23fd). Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1203      +/-   ##
==========================================
- Coverage   99.36%   99.29%   -0.08%     
==========================================
  Files         147      147              
  Lines       20555    20560       +5     
  Branches     3663     3665       +2     
==========================================
- Hits        20425    20415      -10     
- Misses        121      135      +14     
- Partials        9       10       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

codecov[bot] avatar Sep 14 '24 21:09 codecov[bot]

unfortunately i can't say it's working:

❯    apprise -vv -t "Test Title" -b "Test Message" \
  'matrixs://<token>@<hostname>/!<channel-id>'
2024-09-26 09:50:12,914 - WARNING - Failed to handshake with Matrix server: Unauthorized - Invalid Token., error=403.
2024-09-26 09:50:13,109 - WARNING - Failed to handshake with Matrix server: Unauthorized - Invalid Token., error=403.

ClemontX avatar Sep 26 '24 07:09 ClemontX

image

ClemontX avatar Sep 26 '24 07:09 ClemontX

looks like it's going for a registration token instead of an access token.

ClemontX avatar Sep 26 '24 07:09 ClemontX

It almost looks like m.login.token was dropped from the specs entirely (see here).

What happens if you add ? version=2 to the Apprise URL to leverage the legacy Matrix API?

caronc avatar Sep 26 '24 13:09 caronc

Tested and wasn't able to get it working. Would provide logs but nothing printed in terminal.

natoleet avatar Oct 25 '24 11:10 natoleet

Try adding -vvv to the CLI command

caronc avatar Oct 25 '24 22:10 caronc

DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.1062s
DEBUG - Loaded Matrix URL: matrixs://[email protected]/%23alerts?image=no&mode=off&version=3&msgtype=text&format=text&overflow=upstream
DEBUG - Matrix POST URL: https://matrix.DOMAINREDACTED.com/_matrix/client/v3/login (cert_verify=True)
DEBUG - Matrix Payload: {'type': 'm.login.token', 'token': 'TOKENREDACTED'}
DEBUG - Matrix Response: code=403, b'{"errcode":"M_FORBIDDEN","error":"Invalid login token"}'
WARNING - Failed to handshake with Matrix server: Unauthorized - Invalid Token., error=403.
DEBUG - Response Details:
b'{"errcode":"M_FORBIDDEN","error":"Invalid login token"}'
DEBUG - Matrix POST URL: https://matrix.DOMAINREDACTED.com/_matrix/client/v3/register (cert_verify=True)
DEBUG - Matrix Payload: {'kind': 'user', 'auth': {'type': 'm.login.dummy'}, 'password': 'TOKENREDACTED'}
DEBUG - Matrix Response: code=400, b'{"errcode":"M_UNKNOWN","error":"Invalid username"}'
WARNING - Failed to handshake with Matrix server: Bad Request - Unsupported Parameters., error=400.
DEBUG - Response Details:
b'{"errcode":"M_UNKNOWN","error":"Invalid username"}

natoleet avatar Nov 02 '24 04:11 natoleet

Oops I didn't even see this PR. This is also a copy of https://github.com/caronc/apprise/pull/1236

voc0der avatar Nov 19 '24 14:11 voc0der

See #1236

caronc avatar Nov 22 '24 17:11 caronc