How to use the dirac.lib.webconfig.gWebConfig 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 / lib / webBase.py View on Github external
def getHelpForPage(): #by Matvey
  default = "http://marwww.in2p3.fr/~atsareg/Docs/DIRAC/build/html/diracindex.html"
  controller = "%s" % request.environ[ 'pylons.routes_dict' ][ 'controller' ]
  if controller.find( '/' ) > 0:
    prefix, controller = controller.split( '/' );
  helpSection = gWebConfig.getHelpSection()
  if not helpSection:
    return default
  else:
    keys = helpSection.keys()
    if controller in keys:
      return "%s" % helpSection[controller]
    else:
      return default
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / webBase.py View on Github external
def getSchemaContents( section = "" ):
  subContents = []
  for subSection in gWebConfig.getSchemaSections( section ):
    subSectionPath = "%s/%s" % ( section, subSection )
    subJSTxt = getSchemaContents( subSectionPath )
    if len( subJSTxt ) > 0:
      subContents.append( "{ text: '%s', menu : %s }" % ( subSection.capitalize(), subJSTxt ) )
  for page in gWebConfig.getSchemaPages( section ):
    pageData = gWebConfig.getSchemaPageData( "%s/%s" % ( section, page ) )
    if len( pageData ) is not 3:
      continue
    if not checkPropertiesWithUser( pageData[2:] ):
      continue
    if pageData[0].find( "http" ) == 0:
      pagePath = pageData[0]
    else:
      pagePath = diracURL( "/%s" % ( pageData[0] ) )
    subContents.append( "{ text : '%s', url : '%s' }" % ( page, pagePath ) )

  if len( subContents ) > 0:
    return "[%s]" % ",".join( subContents )
  return ""
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / credentials.py View on Github external
def __checkDN( environ ):
  userDN = False
  if 'SERVER_SOFTWARE' not in environ:
    diracLogger.info( "Getting the DN from /Website/DebugDN" )
    userDN = gWebConfig.getDebugDN()
  if 'HTTPS' in environ and environ[ 'HTTPS' ] == 'on':
    if 'SSL_CLIENT_S_DN' in environ:
      userDN = environ[ 'SSL_CLIENT_S_DN' ]
    elif 'SSL_CLIENT_CERT' in environ:
      userCert = X509Certificate.X509Certificate()
      result = userCert.loadFromString( environ[ 'SSL_CLIENT_CERT' ] )
      if not result[ 'OK' ]:
        diracLogger.error( "Could not load SSL_CLIENT_CERT: %s" % result[ 'Message' ] )
        userName = "anonymous"
      else:
        userDN = userCert.getSubjectDN()[ 'Value' ]
    else:
      diracLogger.error( "Web server is not properly configured to get SSL_CLIENT_S_DN or SSL_CLIENT_CERT in env" )
  if not userDN:
    userName = "anonymous"
  else:
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / credentials.py View on Github external
import logging
import os.path
from pylons import request

from dirac.lib.base import *
from dirac.lib.webconfig import gWebConfig
from dirac.lib.sanitizeInputs import sanitizeAllWebInputs

from DIRAC import gLogger
from DIRAC.Core.DISET.AuthManager import AuthManager
from DIRAC.Core.Security import CS, X509Certificate

gAuthManager = AuthManager( "%s/Authorization" % gWebConfig.getWebSection() )

log = logging.getLogger( __name__ )
diracLogger = gLogger.getSubLogger( "Credentials" )

def checkURL( environ, routesDict ):
  #Before all we try to sanitize inputs
  sanitizeAllWebInputs( environ )
  #Time for Auth!
  routesDict[ 'dsetup' ] = __checkSetup( routesDict[ 'dsetup' ] )
  userDN, userName = __checkDN( environ )
  userGroup, availableGroups = __checkGroup( userName, routesDict[ 'dgroup' ] )
  routesDict[ 'dgroup' ] = userGroup
  environ[ 'DIRAC.userCredentials' ] = { 'DN' : userDN,
                                         'username' : userName,
                                         'group' : userGroup,
                                         'availableGroups' : availableGroups
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / webBase.py View on Github external
def jsSchemaSection( area, section ):
  jsTxt = "["
  for subSection in gWebConfig.getSchemaSections( section ):
    subSectionPath = "%s/%s" % ( section, subSection )
    subJSTxt = jsSchemaSection( area, subSectionPath )
    if len( subJSTxt ) > 0:
      jsTxt += "{ text: '%s', submenu : { id: '%s', itemdata : %s } }, " % ( subSection, subSectionPath, subJSTxt )
  for page in gWebConfig.getSchemaPages( section ):
    pageData = gWebConfig.getSchemaPageData( "%s/%s" % ( section, page ) )
    if page != "Delimiter" or len( pageData ) < 3 or 'all' in pageData[2:] or credentials.getSelectedGroup() in pageData[2:]:
      if pageData[0].find( "http" ) == 0:
        pagePath = pageData[0]
      else:
        pagePath = diracURL( "/%s/%s" % ( area, pageData[0] ) )
      jsTxt += "{ text : '%s', url : '%s' }," % ( page, pagePath )
  jsTxt += "]"
  return jsTxt
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / credentials.py View on Github external
def __checkSetup( setup ):
  if setup not in gWebConfig.getSetups():
    return gWebConfig.getDefaultSetup()
  return setup
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / credentials.py View on Github external
def __checkGroup( userName, group ):
  retVal = CS.getGroupsForUser( userName )
  if not retVal[ 'OK' ]:
    availableGroups = []
  else:
    availableGroups = retVal[ 'Value' ]
  if group in availableGroups:
    return ( group, availableGroups )

  defaultGroup = False
  for tgroup in gWebConfig.getDefaultGroups():
    if tgroup in availableGroups:
      defaultGroup = tgroup
      break
  if not defaultGroup:
    defaultGroup = "visitor"
  return ( defaultGroup, availableGroups )