How to use the dirac.lib.credentials.authorizeAction function in DIRAC

To help you get started, we’ve selected a few DIRAC examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / framework.py View on Github external
def manageProxies(self):
    if not authorizeAction():
      return render("/login.mako")
    c.select = self.__getSelectionData()
    return render(  "/systems/framework/manageProxies.mako" )
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / production / ProductionWorkflow.py View on Github external
    @jsonify
    def newWF(self):
      if not authorizeAction():
        return S_ERROR("You are not authorised to create workflows")
      Name = request.params.get('name','')
      Type = request.params.get('type','')
      if not Name:
        return S_ERROR("You have to specify valid unique workflow name");
      try:
        wf = Workflow(name=Name)
        wf.setType(Type)
        wfxml = wf.toXML()
        RPC = getRPCClient("ProductionManagement/ProductionManager")
        result = RPC.publishWorkflow(str(wfxml),False)
      except Exception,msg:
        return S_ERROR(msg)
      if not result['OK']:
        return result
      return S_OK("Created")
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / production / ProductionWorkflow.py View on Github external
def saveWFLocal(self,id):
      if not authorizeAction():
        return self.__authError()
      wf = request.params.get('JSONStr','')
      if wf != '':
        result = _JSToWorkflow(wf)
        if self.__servError(result):
          return render("/error.mako")
        response.headers['Content-type'] = "application/workflow"
        return result['Value'].toXML()
      else:
        result = self.__getWorkflow(id)
        if self.__servError(result):
          return render("/error.mako")
        response.headers['Content-type'] = "application/workflow"
        return result['Value'];
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / framework.py View on Github external
  @jsonify
  def getProxiesList(self):
    if not authorizeAction():
      return {"success":"false","error":"You are not authorize to access these data"}
    start, limit, sort, req = self.__request()
    rpcClient = getRPCClient( "Framework/ProxyManager" )
    retVal = rpcClient.getContents( req, sort, start, limit )
    if not retVal[ 'OK' ]:
      return {"success":"false","error":retVal["Message"]}
    svcData = retVal[ 'Value' ]
    proxies = []
    dnMap = {}
    gLogger.info("!!!  RESULT: %s" % str(svcData) )
    for record in svcData[ 'Records' ]:
      proxies.append( { 'proxyid': "%s@%s" % ( record[1], record[2] ),
                                  'username' : str( record[0] ),
                                  'UserDN' : record[1],
                                  'UserGroup' : record[2],
                                  'ExpirationTime' : str( record[3] ),
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / monitoring.py View on Github external
def deleteActivity( self ):
    """
    Delete an activity
    """
    if not authorizeAction():
      return render( "/error.mako" )
    if not 'sid' in request.params or not 'aid' in request.params:
      c.error = "Missing ids to delete!"
      return render( "/error.mako" )
    try:
      sid = int( request.params[ 'sid' ] )
      aid = int( request.params[ 'aid' ] )
    except Exception, e:
      c.error = "id is not valid"
      return render( "/error.mako" )
    rpcClient = getRPCClient( "Monitoring/Server" )
    retVal = rpcClient.deleteActivity( sid, aid )
    if not retVal[ 'OK' ]:
      c.error = "Error while deleting activity %s" % retVal[ 'Message' ]
      return render( "/error.mako" )
    return redirect_to( 'manageActivities' )
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / monitoring.py View on Github external
def manageActivities( self ):
    """
    Return template for managing views
    """
    if not authorizeAction():
      return render( "/error.mako" )
    rpcClient = getRPCClient( "Monitoring/Server" )
    retVal = rpcClient.getActivities()
    if not retVal[ 'OK' ]:
      c.error = retVal[ 'Message' ]
      return render( "/error.mako" )
    c.activitiesDict = retVal[ 'Value' ]
    return render( "/systems/monitoring/manageActivities.mako" )
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / production / ProductionWorkflow.py View on Github external
    @jsonify
    def copyWF(self):
      if not authorizeAction():
        return S_ERROR("You are not authorised to copy workflows")
      reqjs = request.params.get('JSONStr','')
      try:
        req = simplejson.loads(reqjs)
        name = req["Name"]
        new_name = req["NewName"]
        path = req["Path"]
      except Exception,msg:
        return S_ERROR(msg)
      if name == new_name:
        return S_ERROR("You can't use the same workflow name")
      result = self.__getWorkflow(name)
      if not result["OK"]:
        return result
      wf = fromXMLString(result['Value'])
      wf.setName(new_name)
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / production / ProductionWorkflow.py View on Github external
    @jsonify
    def moveWF(self):
      if not authorizeAction():
        return S_ERROR("You are not authorised to move workflows")
      reqjs = request.params.get('JSONStr','')
      try:
        req = simplejson.loads(reqjs)
        name = req["Name"]
        new_name = req["NewName"]
        path = req["Path"]
      except Exception,msg:
        return S_ERROR(msg)
      result = self.__getWorkflow(name)
      if not result["OK"]:
        return result
      wf = fromXMLString(result['Value'])
      wf.setName(new_name)
      wf.setType(path)
      try:
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / configuration.py View on Github external
def showHistory( self ):
    if not authorizeAction():
      return render( "/error.mako" )
    rpcClient = getRPCClient( gConfig.getValue( "/DIRAC/Configuration/MasterServer", "Configuration/Server" ) )
    retVal = rpcClient.getCommitHistory()
    if retVal[ 'OK' ]:
      cDict = { 'numVersions' : 0, 'versions' : [] }
      for entry in retVal[ 'Value' ]:
        cDict[ 'numVersions' ] += 1
        cDict[ 'versions' ].append( { 'version' : entry[1], 'commiter' : entry[0] } )
      c.versions = simplejson.dumps( cDict )
      return render( "/systems/configuration/showHistory.mako" )
    else:
      c.error = retVal[ 'Message' ]
      return render( "/error.mako" )
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / monitoring.py View on Github external
def manageViews( self ):
    """
    Return template for managing views
    """
    if not authorizeAction():
      return render( "/error.mako" )
    rpcClient = getRPCClient( "Monitoring/Server" )
    retVal = rpcClient.getViews( False )
    if not retVal[ 'OK' ]:
      c.error = retVal[ 'Message' ]
      return render( "/error.mako" )
    c.viewsList = retVal[ 'Value' ]
    return render( "/systems/monitoring/manageViews.mako" )