Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Implement bearer token authentication #3043

Merged
merged 1 commit into from Oct 19, 2022
Merged

Conversation

em92
Copy link
Contributor

@em92 em92 commented Sep 18, 2022

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
Copy link
Contributor

dvikan commented Sep 19, 2022

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
Copy link
Contributor Author

em92 commented Oct 13, 2022

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
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
Copy link
Contributor

dvikan commented Oct 19, 2022

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.

None yet

2 participants