Skip to content

Commit

Permalink
NAS-125070 / 24.04 / Allow all authenticated users to get basic state…
Browse files Browse the repository at this point in the history
… info (#12454)

This allows all authenticated users to retrieve the following
info:

* directory services state (HEALTHY, DISABLED, FAULTED)
* whether system is licensed for failover
* truenas version information
* whether server is clustered
  • Loading branch information
anodos325 authored Nov 6, 2023
1 parent b49f704 commit d74f952
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/middlewared/middlewared/plugins/cluster_linux/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from middlewared.plugins.gluster_linux.utils import GlusterConfig
from middlewared.schema import Bool, returns
from middlewared.service import (Service, ValidationErrors, accepts, job,
private)
private, no_authz_required)
from middlewared.service_exception import CallError
from middlewared.utils.path import CLUSTER_PATH_PREFIX

Expand All @@ -22,6 +22,7 @@ class Config:
namespace = 'cluster.utils'
cli_namespace = 'service.cluster.utils'

@no_authz_required
@accepts()
@returns(Bool('is_clustered'))
async def is_clustered(self):
Expand Down
3 changes: 2 additions & 1 deletion src/middlewared/middlewared/plugins/directoryservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from base64 import b64encode, b64decode
from middlewared.schema import accepts, Dict, List, OROperator, Ref, returns, Str
from middlewared.service import Service, private, job
from middlewared.service import no_authz_required, Service, private, job
from middlewared.plugins.smb import SMBCmd, SMBPath
from middlewared.service_exception import CallError
from middlewared.utils import run
Expand Down Expand Up @@ -141,6 +141,7 @@ class Config:
service = "directoryservices"
cli_namespace = "directory_service"

@no_authz_required
@accepts()
@returns(Dict(
'directory_services_states',
Expand Down
4 changes: 3 additions & 1 deletion src/middlewared/middlewared/plugins/failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from middlewared.auth import is_ha_connection, TrueNasNodeSessionManagerCredentials
from middlewared.schema import accepts, Bool, Dict, Int, List, NOT_PROVIDED, Str, returns, Patch
from middlewared.service import (
job, no_auth_required, pass_app, private, CallError, ConfigService, ValidationError, ValidationErrors
job, no_auth_required, no_authz_required, pass_app, private, CallError, ConfigService,
ValidationError, ValidationErrors
)
import middlewared.sqlalchemy as sa
from middlewared.plugins.auth import AuthService
Expand Down Expand Up @@ -134,6 +135,7 @@ async def _master_node(self, master):
else:
raise CallError('Unable to change node state in MANUAL mode')

@no_authz_required
@accepts()
@returns(Bool())
def licensed(self):
Expand Down
5 changes: 4 additions & 1 deletion src/middlewared/middlewared/plugins/system/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path

from middlewared.schema import accepts, Bool, returns, Str
from middlewared.service import CallError, no_auth_required, private, Service
from middlewared.service import CallError, no_auth_required, no_authz_required, private, Service
from middlewared.utils import sw_info
from middlewared.utils.license import LICENSE_ADDHW_MAPPING

Expand Down Expand Up @@ -78,6 +78,7 @@ async def product_name(self):
"""
return "TrueNAS"

@no_authz_required
@accepts()
@returns(Str('truenas_version_shortname'))
def version_short(self):
Expand Down Expand Up @@ -105,12 +106,14 @@ def release_notes_url(self, version_str):
else:
return f'{base_url}/#{"".join(to_format)}'

@no_authz_required
@accepts()
@returns(Str('truenas_version'))
def version(self):
"""Returns the full name of the software version of the system."""
return sw_info()['fullname']

@no_authz_required
@accepts()
@returns(Str('is_stable'))
def is_stable(self):
Expand Down

0 comments on commit d74f952

Please sign in to comment.