-
Notifications
You must be signed in to change notification settings - Fork 94
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
flow-cfg-update.authentication #3845
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Server for suite runtime API.""" | ||
|
||
import getpass | ||
import getpass # noqa: F401 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this F401 for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getpass is not used overtly, but causes failures if it's removed. Detailed cause not investigated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What failures occurred? I just tried removing this line and didn't see any problems on running a flow. |
||
from queue import Queue | ||
from textwrap import dedent | ||
from time import sleep | ||
|
@@ -24,9 +24,8 @@ | |
import zmq | ||
|
||
from cylc.flow import LOG | ||
from cylc.flow.cfgspec.glbl_cfg import glbl_cfg | ||
from cylc.flow.network import encode_, decode_, ZMQSocketBase | ||
from cylc.flow.network.authorisation import Priv, authorise | ||
from cylc.flow.network.authorisation import authorise | ||
from cylc.flow.network.graphql import ( | ||
CylcGraphQLBackend, IgnoreFieldMiddleware, instantiate_middleware | ||
) | ||
|
@@ -254,30 +253,13 @@ def _receiver(self, message): | |
|
||
return {'data': response} | ||
|
||
def _get_public_priv(self): | ||
"""Return the public privilege level of this suite.""" | ||
if self.schd.config.cfg['cylc']['authentication']['public']: | ||
return Priv.parse( | ||
self.schd.config.cfg['cylc']['authentication']['public']) | ||
return Priv.parse(glbl_cfg().get(['authentication', 'public'])) | ||
|
||
def _get_priv_level(self, user): | ||
"""Return the privilege level for the given user for this suite.""" | ||
if user == getpass.getuser(): | ||
return Priv.CONTROL | ||
if self.public_priv is None: | ||
# cannot do this on initialisation as the suite configuration has | ||
# not yet been parsed | ||
self.public_priv = self._get_public_priv() | ||
return self.public_priv | ||
|
||
def register_endpoints(self): | ||
"""Register all exposed methods.""" | ||
self.endpoints = {name: obj | ||
for name, obj in self.__class__.__dict__.items() | ||
if hasattr(obj, 'exposed')} | ||
|
||
@authorise(Priv.IDENTITY) | ||
@authorise() | ||
@expose | ||
def api(self, endpoint=None): | ||
"""Return information about this API. | ||
|
@@ -310,7 +292,7 @@ def api(self, endpoint=None): | |
return '%s\n%s' % (head, tail) | ||
return 'No method by name "%s"' % endpoint | ||
|
||
@authorise(Priv.READ) | ||
@authorise() | ||
@expose | ||
def graphql(self, request_string=None, variables=None): | ||
"""Return the GraphQL scheme execution result. | ||
|
@@ -353,7 +335,7 @@ def graphql(self, request_string=None, variables=None): | |
return errors | ||
return executed.data | ||
|
||
@authorise(Priv.READ) | ||
@authorise() | ||
@expose | ||
def get_graph_raw(self, start_point_string, stop_point_string, | ||
group_nodes=None, ungroup_nodes=None, | ||
|
@@ -418,7 +400,7 @@ def get_graph_raw(self, start_point_string, stop_point_string, | |
ungroup_all=ungroup_all) | ||
|
||
# UIServer Data Commands | ||
@authorise(Priv.READ) | ||
@authorise() | ||
@expose | ||
def pb_entire_workflow(self): | ||
"""Send the entire data-store in a single Protobuf message. | ||
|
@@ -431,7 +413,7 @@ def pb_entire_workflow(self): | |
pb_msg = self.schd.data_store_mgr.get_entire_workflow() | ||
return pb_msg.SerializeToString() | ||
|
||
@authorise(Priv.READ) | ||
@authorise() | ||
@expose | ||
def pb_data_elements(self, element_type): | ||
"""Send the specified data elements in delta form. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove the
Priv
class (as this PR effectively removes authorisation) and kill theif usr_priv_level < req_priv_level:
check.