This supports public instances by disabling any kind of unauthorized action.
There's a problem with sources: these are not correctly being fetched because we use the /sources/list api endpoint which is not publicly accessible rather than /sources/stats which is. https://github.com/fossar/selfoss/issues/1403
I'm unsure whether to include changes to fetching sources in this PR or to create a new one for that. This is currently complete and working, however it's impossible to filter by source.
## Types of changes
- [x] I have read the **CONTRIBUTING** document.
- [x] My code follows the code style of this project.
- [ ] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] This is **NOT** translation related.
This is implements feature #106
This supports public instances by disabling any kind of unauthorized action.
There's a problem with sources: these are not correctly being fetched because we use the /sources/list api endpoint which is not publicly accessible rather than /sources/stats which is. https://github.com/fossar/selfoss/issues/1403
I'm unsure whether to include changes to fetching sources in this PR or to create a new one for that. This is currently complete and working, however it's impossible to filter by source.
Fetch from /api/about the selfoss configuration to determine if we're using a public access instanceIf both authentication and public mode are enabled in the configuration and we're logging in without authentication, then we're using public access.
In public access mode we can only read articles. Disable swiping articles in the listing to read them and remove the menu items to read all articles and to access sources settings.
We do not care about the value of appSettingsService.getPublicAccess() if appSettingsService.isMarkOnScrollEnabled() is false.
`and` should be changed to `&&`.
We do not care about the value of `appSettingsService.getPublicAccess()` if `appSettingsService.isMarkOnScrollEnabled()` is false.
The button order stays the same in the application as it currently is. This change allows the buttons to disappear dynamically and still align to the end of the layout.
The button order stays the same in the application as it currently is. This change allows the buttons to disappear dynamically and still align to the end of the layout.
I didn't look into how public instances work, but this condition seems weird.
isAuthEnabled and isPublicModeEnabled can be true at the same time ?
They seem to mean different things.
I didn't look into how public instances work, but this condition seems weird.
`isAuthEnabled` and `isPublicModeEnabled` can be `true` at the same time ?
They seem to mean different things.
Yes, it is the normal case in fact; the weird condition is actually isAuthEnabledfalse and isPublicModeEnabledtrue.
Authentication is enabled because the administrator user can log in and read/favourite articles or edit sources while everyone else can just read the articles (and not mark them as read). Having authentication disabled simply means that no password is required to access and thus everyone is administrator, in this case it would make no sense to enable public mode as well.
Yes, it is the normal case in fact; the weird condition is actually `isAuthEnabled` `false` and `isPublicModeEnabled` `true`.
Authentication is enabled because the administrator user can log in and read/favourite articles or edit sources while everyone else can just read the articles (and not mark them as read). Having authentication disabled simply means that no password is required to access and thus everyone is administrator, in this case it would make no sense to enable public mode as well.
No, public mode might be enabled but we could still log into the instance with username and password.
Public mode has limitations, thus if one had the credentials to access the instance, that would actually be the preferred option.
No, public mode might be enabled but we could still log into the instance with username and password.
Public mode has limitations, thus if one had the credentials to access the instance, that would actually be the preferred option.
I'll rectify to explain what I mean. In the settings I am not storing the remote value of the configuration, I am directly storing whether we connected through public mode or not; in this way in any point of the application in which this information is required, that'll be readily available without any further processing. That's because we could connect trough the normal authentication method even if public mode was enabled.
Alternatively, I'd have to store both values of the remote configuration: isPublicModeEnabled and isAuthEnabled and each time check if these imply that we're connecting through public mode.
Since we are not using these information for anything else, storing it would be redundant.
I'll rectify to explain what I mean. In the settings I am not storing the remote value of the configuration, I am directly storing whether we connected through public mode or not; in this way in any point of the application in which this information is required, that'll be readily available without any further processing. That's because we could connect trough the normal authentication method even if public mode was enabled.
Alternatively, I'd have to store both values of the remote configuration: `isPublicModeEnabled` and `isAuthEnabled` and each time check if these imply that we're connecting through public mode.
Since we are not using these information for anything else, storing it would be redundant.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Types of changes
This is implements feature #106
This supports public instances by disabling any kind of unauthorized action.
There's a problem with sources: these are not correctly being fetched because we use the /sources/list api endpoint which is not publicly accessible rather than /sources/stats which is. https://github.com/fossar/selfoss/issues/1403
I'm unsure whether to include changes to fetching sources in this PR or to create a new one for that. This is currently complete and working, however it's impossible to filter by source.
@@ -85,3 +85,3 @@private fun readItem(item: SelfossModel.Item) {if (appSettingsService.isMarkOnScrollEnabled()) {if (appSettingsService.isMarkOnScrollEnabled() and !appSettingsService.getPublicAccess()) {andshould be changed to&&.We do not care about the value of
appSettingsService.getPublicAccess()ifappSettingsService.isMarkOnScrollEnabled()is false.@@ -95,4 +94,3 @@app:layout_constraintTop_toBottomOf="@+id/sourceTitleAndDate"><ImageButtonandroid:id="@+id/favButton"Why was the buttons order changed ?
The button order stays the same in the application as it currently is. This change allows the buttons to disappear dynamically and still align to the end of the layout.
@@ -49,0 +51,4 @@fun getApiConfiguration() = configuration ?: ApiConfiguration(null, null)}@kotlinx.serialization.SerializableCan be changed to
@Serializable@@ -449,0 +450,4 @@}if (appSettingsService.getUserName().isEmpty()&& fetchedInformation.data.getApiConfiguration().isAuthEnabled()&& fetchedInformation.data.getApiConfiguration().isPublicModeEnabled()) {I didn't look into how public instances work, but this condition seems weird.
isAuthEnabledandisPublicModeEnabledcan betrueat the same time ?They seem to mean different things.
Yes, it is the normal case in fact; the weird condition is actually
isAuthEnabledfalseandisPublicModeEnabledtrue.Authentication is enabled because the administrator user can log in and read/favourite articles or edit sources while everyone else can just read the articles (and not mark them as read). Having authentication disabled simply means that no password is required to access and thus everyone is administrator, in this case it would make no sense to enable public mode as well.
Can you please add this to a comment ?
@@ -449,0 +451,4 @@if (appSettingsService.getUserName().isEmpty()&& fetchedInformation.data.getApiConfiguration().isAuthEnabled()&& fetchedInformation.data.getApiConfiguration().isPublicModeEnabled()) {appSettingsService.updatePublicAccess(true)appSettingsService.updatePublicAccess(fetchedInformation.data.getApiConfiguration().isPublicModeEnabled())isn't enough ?No, public mode might be enabled but we could still log into the instance with username and password.
Public mode has limitations, thus if one had the credentials to access the instance, that would actually be the preferred option.
I'll rectify to explain what I mean. In the settings I am not storing the remote value of the configuration, I am directly storing whether we connected through public mode or not; in this way in any point of the application in which this information is required, that'll be readily available without any further processing. That's because we could connect trough the normal authentication method even if public mode was enabled.
Alternatively, I'd have to store both values of the remote configuration:
isPublicModeEnabledandisAuthEnabledand each time check if these imply that we're connecting through public mode.Since we are not using these information for anything else, storing it would be redundant.