Skip to content

[core] Implement bearer token authentication - #3043

Merged
dvikan merged 1 commit into
RSS-Bridge:masterfrom
em92:api-auth
Oct 19, 2022
Merged

[core] Implement bearer token authentication#3043
dvikan merged 1 commit into
RSS-Bridge:masterfrom
em92:api-auth

Conversation

@em92

@em92 em92 commented Sep 18, 2022

Copy link
Copy Markdown
Contributor

This will allow to write actions, that should be authorized only by instance admin.

For example in my WIP InstagramBridge modifications there 2 actions, that use this feature.

https://github.com/em92/rss-bridge/blob/instagram-rabbitmq/actions/SetBridgeCacheAction.php
https://github.com/em92/rss-bridge/blob/instagram-rabbitmq/actions/PullJobQueueAction.php

@em92
em92 marked this pull request as draft September 18, 2022 16:09
@em92
em92 marked this pull request as ready for review September 18, 2022 16:10
@dvikan

dvikan commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

This pr reminds me of a previous issue where they wanted to use an api key in the url to access feeds. This is because their client didnt support HTTP BASIC AUTH.

I prefer to just put this parameter in the url e.g. ?action=ClearCache&key=f423f34f3f3f

Because will make it very use to just e.g. invoke curl without messing with headers.

Also maybe reuse the authentication section from config?

; Enables authentication for all requests to this RSS-Bridge instance.
;
; Warning: You'll have to upgrade existing feeds after enabling this option!
;
; true  = enabled
; false = disabled (default)
enable = false

username = "admin"

; This default password is public knowledge. Replace it.
password = "hunter2"

I prefer ApiAuthenticationMiddleware over APIAuthenticationMiddleware

Lastly I dont think those http codes 403 are sent to client.

@em92

em92 commented Oct 13, 2022

Copy link
Copy Markdown
Contributor Author

I prefer to just put this parameter in the url

As result, I will keep both methods, using header and using query parameters. First one is for security, second for easy usage.

}

if (!$accessTokenGiven) {
$this->exit('No access token given', 403);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

401 Unauthorized is the status code to return when the client provides no credentials or invalid credentials. 403 Forbidden is the status code to return when a client has valid credentials but not enough privileges to perform an action on a resource.

@dvikan

dvikan commented Oct 19, 2022

Copy link
Copy Markdown
Contributor

This class is not in use right now and is a useful class for protecting resources that require the use of access_token. Also nice with a new config access_token that can be used for lots of things.

@dvikan
dvikan merged commit d483bf2 into RSS-Bridge:master Oct 19, 2022
@em92
em92 deleted the api-auth branch October 19, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants