--- /dev/null
+unfold.wsgi
\ No newline at end of file
--- /dev/null
+NameVirtualHost *:80
+<VirtualHost *:80>
+ ServerName 200.130.15.182
+ ServerSignature Off
+
+ # Redirecionamento para SSL
+ #RewriteEngine on
+ #RewriteCond %{HTTPS} !=on
+ #RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
+
+ DocumentRoot /var/www/
+ <Directory /var/www/>
+ Options Indexes FollowSymLinks MultiViews
+ AllowOverride None
+ Order allow,deny
+ allow from all
+ </Directory>
+
+ ErrorLog /var/log/apache2/error.log
+ # Possible values include: debug, info, notice, warn, error, crit,
+ # alert, emerg.
+ LogLevel info
+ CustomLog /var/log/apache2/sp-access-80.log combined
+</VirtualHost>
--- /dev/null
+NameVirtualHost *:443
+<IfModule mod_ssl.c>
+<VirtualHost *:443>
+ ServerAdmin support-myslice@myslice.info
+ ServerName portal.fibre.br
+
+ DocumentRoot /var/www/myslice
+ WSGIScriptAlias / /var/www/myslice/apache/unfold.wsgi
+
+ <Directory /var/www/myslice>
+ Options Indexes FollowSymLinks MultiViews
+ AllowOverride All
+ Order allow,deny
+ allow from all
+ </Directory>
+
+ Alias /static/ /var/www/myslice/static/
+ <Directory /var/www/myslice/static>
+ Order deny,allow
+ Allow from all
+ </Directory>
+
+ #Alias /certificates/ /var/certificates-f4f/
+ ErrorLog ${APACHE_LOG_DIR}/error.log
+
+ LogLevel warn
+
+ CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
+
+ # SSL
+ SSLEngine on
+ SSLProtocol all -SSLv2
+ SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
+ SSLCertificateKeyFile /etc/ssl/private/fibre.key
+ SSLCertificateFile /etc/ssl/certs/fibre.crt
+ SSLOptions +StdEnvVars +ExportCertData
+ SSLCACertificatePath /etc/sfa/trusted_roots
+ SSLVerifyClient optional_no_ca
+ #SSLVerifyClient require
+ SSLVerifyDepth 5
+ ServerSignature On
+
+ <FilesMatch "\.(cgi|shtml|phtml|php)$">
+ SSLOptions +StdEnvVars
+ </FilesMatch>
+ <Directory /usr/lib/cgi-bin>
+ SSLOptions +StdEnvVars
+ </Directory>
+
+ BrowserMatch "MSIE [2-6]" \
+ nokeepalive ssl-unclean-shutdown \
+ downgrade-1.0 force-response-1.0
+ BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
+
+</VirtualHost>
+</IfModule>
--- /dev/null
+<VirtualHost 200.130.15.182:443>
+ ServerName 200.130.15.182
+ ServerSignature Off
+
+ SSLEngine on
+ #SSLCertificateFile /etc/unfold/trusted_roots
+ SSLCertificateFile /etc/ssl/certs/fibre.crt
+ SSLCertificateKeyFile /etc/ssl/private/fibre.key
+
+ #ShibURLScheme https
+
+ DocumentRoot /var/www/
+ <Directory /var/www/>
+ Options -Indexes FollowSymLinks -MultiViews
+ AllowOverride None
+ Order deny,allow
+ Allow from all
+ </Directory>
+
+# WSGIScriptAlias / /usr/share/unfold/apache/myslice.wsgi
+# <Directory /usr/share/unfold/apache>
+# <Files myslice.wsgi>
+# Order deny,allow
+# Allow from all
+# </Files>
+# </Directory>
+# Alias /static/ /usr/share/unfold/static/
+# <Directory /usr/share/unfold/static>
+# Order deny,allow
+# Allow from all
+# </Directory>
+
+
+#<Location myslice/secure>
+# AuthType Shibboleth
+# ShibRequestSetting requireSession true
+# ShibRequestSetting applicationId default
+# Require valid-user
+#</Location>
+
+<Location /Shibboleth.sso>
+ SetHandler shib
+</Location>
+<Location /shibboleth-sp2>
+ SetHandler shib
+</Location>
+
+
+# <Location /moodle/auth/shibboleth>
+# AuthType shibboleth
+# ShibRequireSession On
+# require valid-user
+# </Location>
+
+ # Possible values include: debug, info, notice, warn, error, crit,
+ # alert, emerg.
+ ErrorLog /var/log/apache2/error.log
+ LogLevel info
+ CustomLog /var/log/apache2/sp-access-443.log combined
+
+</VirtualHost>
# see also unfold-ssl.conf
<VirtualHost *:80>
- WSGIDaemonProcess unfold processes=2 threads=25
- WSGIProcessGroup unfold
- CustomLog ${APACHE_LOG_DIR}/unfold-access.log common
- ErrorLog ${APACHE_LOG_DIR}/unfold-error.log
- WSGIScriptAlias / /usr/share/unfold/apache/unfold.wsgi
- <Directory /usr/share/unfold/apache/>
- <Files unfold.wsgi>
+ WSGIDaemonProcess myslice processes=2 threads=25
+ WSGIProcessGroup myslice
+ CustomLog ${APACHE_LOG_DIR}/myslice-access.log common
+ ErrorLog ${APACHE_LOG_DIR}/myslice-error.log
+ WSGIScriptAlias / /var/www/myslice/apache/myslice.wsgi
+ <Directory /var/www/myslice/myslice/apache/>
+ <Files myslice.wsgi>
Order deny,allow
Allow from all
</Files>
</Directory>
- Alias /static/ /usr/share/unfold/static/
- <Directory /usr/share/unfold/static>
+ Alias /static/ /var/www/myslice/myslice/static/
+ <Directory /var/www/myslicee/myslice/static>
Order deny,allow
Allow from all
</Directory>
import os
import sys
+#site.addsitedir('/var/www/myslice')
+
+path = '/var/www/myslice'
+if path not in sys.path:
+ sys.path = [path] + sys.path
+print sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'myslice.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
-
import time
+# import ldap for LDAP authentication - Edelberto
+import ldap
+
from django.contrib.auth.models import User
from manifoldapi.manifoldapi import ManifoldAPI, ManifoldException, ManifoldResult
# Name my backend 'ManifoldBackend'
class ManifoldBackend:
+
# Create an authentication method
# This is called by the standard Django login procedure
def authenticate(self, token=None):
+
+ # LDAP local/global var
+ checkldap = None
+
if not token:
return None
try:
+ #usernameldap is from LDAP user form. If it is filled - See portal/homeview.py too
+ usernameldap = token['usernameldap']
username = token['username']
password = token['password']
request = token['request']
- auth = {'AuthMethod': 'password', 'Username': username, 'AuthString': password}
- api = ManifoldAPI(auth)
- sessions_result = api.forward(Query.create('local:session').to_dict())
- print "result"
- sessions = sessions_result.ok_value()
- print "ok"
- if not sessions:
- print "GetSession failed", sessions_result.error()
- return
- print "first", sessions
- session = sessions[0]
-
- # Change to session authentication
- api.auth = {'AuthMethod': 'session', 'session': session['session']}
- self.api = api
-
- # Get account details
- # the new API would expect Get('local:user') instead
- persons_result = api.forward(Query.get('local:user').to_dict())
- persons = persons_result.ok_value()
- if not persons:
- print "GetPersons failed",persons_result.error()
- return
- person = persons[0]
- print "PERSON=", person
-
- request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': session['expires']}
+ # if data are not from LDAP form then normal (local) login
+ if not usernameldap:
+ auth = {'AuthMethod': 'password', 'Username': username, 'AuthString': password}
+ api = ManifoldAPI(auth)
+ sessions_result = api.forward(Query.create('local:session').to_dict())
+ print "result"
+ sessions = sessions_result.ok_value()
+ print "ok"
+ if not sessions:
+ print "GetSession failed", sessions_result.error()
+ return
+ print "first", sessions
+ session = sessions[0]
+
+ # Change to session authentication
+ api.auth = {'AuthMethod': 'session', 'session': session['session']}
+ self.api = api
+
+ # Get account details
+ # the new API would expect Get('local:user') instead
+ persons_result = api.forward(Query.get('local:user').to_dict())
+ persons = persons_result.ok_value()
+ if not persons:
+ print "GetPersons failed",persons_result.error()
+ return
+ person = persons[0]
+ print "PERSON=", person
+
+ request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': session['expires']}
+ ################################
+ # Edelberto LDAP authentication
+ # if data are from LDAP form, so
+ else:
+ # XXX UGLY
+ # Needing to create an specif entries at settings.py (or myslice.ini) for these vars
+ ##################################################
+ # Edelberto - UFF - esilva@ic.uff.br
+ # v1 - ldap authentication module
+ # Note: focus on LDAP FIBRE-BR for DN
+ # if uses other DN, configuration are needed
+ ###################################################
+ #Searching an LDAP Directory
+
+ try:
+ #uid = "debora@uff.br"
+
+ # Receiving an email address, how can we split and mount it in DN format?
+ #mail = "debora@uff.br"
+ mail = usernameldap
+ login = mail.split('@')[0]
+ org = mail.split('@')[1]
+ o = org.split('.')[0]
+ dc = org.split('.')[1]
+ '''
+ print mail
+ print login
+ print org
+ print o
+ print dc
+ '''
+
+ # DN format to authenticate - IMPORTANT!
+ #FIBRE-BR format
+ uid = "uid="+mail+",ou=people,o="+o+",dc="+dc
+ #uid = "uid=debora@uff.br,ou=people,o=uff,dc=br"
+ # User password from LDAP form
+ #userPassword = "fibre"
+ userPassword = password
+
+ # testing with:
+ # wrong password for test
+ # userPassword = "fibre2"
+
+ # Parameters to connect on LDAP
+ ldap.set_option(ldap.OPT_REFERRALS, 0)
+ # LDAP Server Address
+ l = ldap.open("127.0.0.1")
+ # LDAP version
+ l.protocol_version = ldap.VERSION3
+
+ #l.simple_bind(uid, userPassword)
+ # l.bind_s is necessary to do the authentication with a normal LDAP user
+ l.bind_s(uid, userPassword, ldap.AUTH_SIMPLE)
+ #print l.bind_s(uid, userPassword, ldap.AUTH_SIMPLE)
+
+ # DN base - Our root dc (dc=br)
+ baseDN="dc="+dc
+ searchScope = ldap.SCOPE_SUBTREE
+ retrieveAttributes = None
+ # User only can see its credentials. He search only his attributes
+ searchFilter = "uid="+mail
+
+ # Getting all attributes
+ try:
+ ldap_result_id = l.search(baseDN, searchScope, searchFilter, retrieveAttributes)
+ result_set = []
+ # while exist attributes, save them in a list!
+ while 1:
+ # print l.result(ldap_result_id, 0)
+ result_type, result_data = l.result(ldap_result_id, 0)
+ if (result_data == []):
+ #print ("User %s don't allowed to bind in LDAP", uid)
+ break
+ else:
+ ## Appendng to a list
+ if result_type == ldap.RES_SEARCH_ENTRY:
+ result_set.append(result_data)
+ # print result_set
+ except ldap.LDAPError, e:
+ print e
+
+ # Matching if the user is really who his say
+ #checkldap = None
+ if l.compare_s(uid, 'uid', mail):
+ # DEBUG
+ checkldap = True
+ print "match"
+
+ # Now, based on default Manifold Auth
+ auth = {'AuthMethod': 'password', 'Username': usernameldap, 'AuthString': password}
+ api = ManifoldAPI(auth)
+ sessions_result = api.forward(Query.create('local:session').to_dict())
+ print "result"
+ sessions = sessions_result.ok_value()
+ print "ok"
+ if not sessions:
+ print "GetSession failed", sessions_result.error()
+ return
+ print "first", sessions
+ session = sessions[0]
+
+ # Change to session authentication
+ api.auth = {'AuthMethod': 'session', 'session': session['session']}
+ self.api = api
+
+ # Get account details
+ # the new API would expect Get('local:user') instead
+ persons_result = api.forward(Query.get('local:user').to_dict())
+ persons = persons_result.ok_value()
+ if not persons:
+ print "GetPersons failed",persons_result.error()
+ return
+ person = persons[0]
+ print "PERSON=", person
+
+ request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': session['expires']}
+
+ else:
+ print "no match. User doesnt allowed"
+ checkldap = False
+
+ except ldap.LDAPError, e:
+ print "E: LDAP Search user", e
+ # end of LDAP
+
+ # Follow the same of Manifold
except ManifoldException, e:
print "ManifoldBackend.authenticate caught ManifoldException, returning corresponding ManifoldResult"
return e.manifold_result
import traceback
traceback.print_exc()
return None
-
- try:
- # Check if the user exists in Django's local database
- user = User.objects.get(username=username)
- except User.DoesNotExist:
- # Create a user in Django's local database
- user = User.objects.create_user(username, username, 'passworddoesntmatter')
- user.first_name = "DUMMY_FIRST_NAME" #person['first_name']
- user.last_name = "DUMMY LAST NAME" # person['last_name']
- user.email = person['email']
- return user
+
+ if not usernameldap:
+ try:
+ # Check if the user exists in Django's local database
+ user = User.objects.get(username=username)
+ except User.DoesNotExist:
+ # Create a user in Django's local database
+ user = User.objects.create_user(username, usernamep, 'passworddoesntmatter')
+ user.first_name = "DUMMY_FIRST_NAME" #person['first_name']
+ user.last_name = "DUMMY LAST NAME" # person['last_name']
+ user.email = person['email']
+ return user
+ else:
+ if checkldap:
+ try:
+ # Check if the user exists in Django's local database
+ user = User.objects.get(username=usernameldap)
+ except User.DoesNotExist:
+ # Create a user in Django's local database
+ user = User.objects.create_user(username, usernameldap, 'passworddoesntmatter')
+ user.first_name = "DUMMY_FIRST_NAME" #person['first_name']
+ user.last_name = "DUMMY LAST NAME" # person['last_name']
+ user.email = person['email']
+ return user
# Required for your backend to work properly - unchanged in most scenarios
def get_user(self, user_id):
default_manifold_admin_user = 'admin'
default_manifold_admin_password = 'demo'
- default_myslice_theme = 'onelab'
+ default_myslice_theme = 'fibre'
def __init__ (self):
parser.add_section('googlemap')
parser.set ('googlemap','api_key', None)
+ print os.path.join(ROOT,'myslice/myslice.ini')
parser.read (os.path.join(ROOT,'myslice/myslice.ini'))
+ print parser
self.config_parser=parser
def __getattr__(self, section):
# when deployed from a package
# this code is run by collectstatic too, so we cannot
# assume we have ./static present already
-HTTPROOT="/usr/share/unfold"
+HTTPROOT="/var/www/myslice"
# the place to store local data, like e.g. the sqlite db
-DATAROOT="/var/unfold"
+DATAROOT="/var/www/myslice"
# if not there, then we assume it's from a devel tree
if not os.path.isdir (os.path.join(HTTPROOT,"static")):
HTTPROOT=ROOT
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'unfold.wsgi.application'
+#WSGI_APPLICATION = 'myslice.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
+ #os.path.join(HTTPROOT,"templates"),
os.path.join(HTTPROOT,"templates"),
)
urls.append ( url ( r'^%s/'%aux, include ('%s.urls'%aux )))
urlpatterns = patterns(*urls)
+
+# Shibboleth - Edelberto
+urlpatterns += patterns('',
+ #url(r'^cafe/', 'plugins.cafe.edelberto.EdelbertoView.as_view()'),
+ url(r'^cafe/', 'plugins.cafe.edelberto.index'),
+)
+
--- /dev/null
+cafe-1.0/
\ No newline at end of file
--- /dev/null
+cafe/
\ No newline at end of file
--- /dev/null
+#!/usr/bin/env python
+
+#Edelberto from manifoldauth
+import os,sys
+import subprocess
+import shlex
+import getpass
+from hashlib import md5
+import time
+from random import Random
+import crypt
+
+import re
+#from manifold.manifold.core.router import Router
+from manifold.core.query import Query
+from manifoldapi.manifoldapi import execute_admin_query
+from portal.actions import manifold_add_user, manifold_add_account, manifold_update_account
+from manifold.core.query import Query
+# add user to manifold
+
+from django.views.generic import View
+from django.core.context_processors import csrf
+#from django.http import HttpResponseRedirect
+from django.contrib.auth import authenticate, login, logout
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+
+from manifold.manifoldresult import ManifoldResult
+from ui.topmenu import topmenu_items, the_user
+from myslice.configengine import ConfigEngine
+
+#from django.http import HttpResponse HttpResponseRedirect
+from django.http import HttpResponse
+#from django.http import HttpResponseRedirect
+#from django.template import RequestContext
+from django.contrib.sessions.backends.db import SessionStore
+
+def index(request):
+#class EdelbertoView (View):
+
+# =================== Old code - to validate =================
+ '''
+ ip = "<html><body>"
+ ip += "cn: " + request.META['Shib-inetOrgPerson-cn'] + "</br>"
+ ip += "sn: " + request.META['Shib-inetOrgPerson-sn'] + "</br>"
+ ip += "eppn: " + request.META['Shib-eduPerson-eduPersonPrincipalName'] + "</br>"
+ ip += "mail: " + request.META['Shib-inetOrgPerson-mail'] + "</br>"
+ ip += "Affiliation br: " + request.META['Shib-brEduPerson-brEduAffiliationType'] + "</br>"
+ ip += "Affiliation edu: " + request.META['Shib-eduPerson-eduPersonAffiliation'] + "</br>"
+ ip += "Auth-Method: " + request.META['Shib-Authentication-Method'] + "</br>"
+ ip += "Identity Provider: " + request.META['Shib-Identity-Provider'] + "</br>"
+ ip += "Application ID: " + request.META['Shib-Application-ID'] + "</br>"
+ ip += "Session ID: " + request.META['Shib-Session-ID'] + "</br>"
+ '''
+# Test cookie support
+ if request.session.test_cookie_worked():
+ #if session.test_cookie_worked():
+ return HttpResponse("Please enable cookies and try again.")
+ #return
+ print "Please enable cookies and try again."
+ else:
+ request.session['cn'] = request.META['Shib-inetOrgPerson-cn']
+ request.session['sn'] = request.META['Shib-inetOrgPerson-sn']
+ request.session['mail'] = request.META['Shib-inetOrgPerson-mail']
+ request.session['eppn'] = request.META['Shib-eduPerson-eduPersonPrincipalName']
+ #request.session['aff'] = request.META['Shib-brEduPerson-brEduAffiliationType']
+ request.session['aff'] = request.META['Shib-eduPerson-eduPersonAffiliation']
+ request.session['shib'] = request.META['Shib-Session-ID']
+
+ if 'mail' in request.session.keys():
+ print "Cookie: OK -> Content: cn:" + request.session["cn"] + " sn " +request.session["sn"] + " mail: " + request.session["mail"] + " eppn: " + request.session["eppn"]
+ #ip += "Cookie: OK -> Content: cn:" + request.session["cn"] + " mail: " + request.session["mail"] + " eppn: " + request.session["eppn"] + "</body></html>"
+ else:
+ print "Cookie: nothing/clear"
+ #ip += "Cookie: nothing/clear </body></html>"
+
+ # return HttpResponse(ip)
+
+
+ # expose this so we can mention the backend URL on the welcome page
+ def default_env (self):
+ config=Config()
+ return {
+ 'MANIFOLD_URL':config.manifold_url(),
+ }
+
+ #def post (self,request):
+ # env = self.default_env()
+ #username = request.POST.get('username')
+ #password = request.POST.get('password')
+ # if we use ABAC based on 'aff'
+ #if 'aff' in request.session.keys():
+ aff = request.session["aff"]
+ # if we use ABAC - based on 'aff'
+ #if aff == "student":
+ # XXX It's only to test the association of admin and esilva@uff.br
+ if request.session["eppn"] == 'esilva@uff.br':
+ username = 'admin'
+ password = 'admin'
+ # For all users
+ else:
+ username = request.session["mail"]
+ # this is ugly. We generate a simple password with merge of mail and a string.
+ password = request.session["mail"] + "fibre2013"
+
+ username = username.replace('"','').strip()
+ password = password.replace('"','').strip()
+ # pass request within the token, so manifold session key can be attached to the request session.
+ token = {'username': username, 'password': password, 'request': request}
+
+ # our authenticate function returns either
+ # . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
+ # . a django User in case of success
+ # . or None if the backend could be reached but the authentication failed
+ auth_result = authenticate(token=token)
+ # high-level errors, like connection refused or the like
+
+ if isinstance (auth_result, ManifoldResult):
+ manifoldresult = auth_result
+ # let's use ManifoldResult.__repr__
+ '''
+ env['state']="%s"%manifoldresult
+ return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ '''
+ htm = "<meta http-equiv=\"refresh\" content=\"0; url=https://sp-fibre.cafeexpresso.rnp.br/login-ok\" />"
+ return HttpResponse (htm)
+ # user was authenticated at the backend
+ elif auth_result is not None:
+ user=auth_result
+
+ if user.is_active:
+ print "LOGGING IN"
+ login(request, user)
+ htm = "<meta http-equiv=\"refresh\" content=\"0; url=https://sp-fibre.cafeexpresso.rnp.br/login-ok\" />"
+ #return HttpResponseRedirect ('/login-ok')
+ return HttpResponse (htm)
+ else:
+ env['state'] = "Your account is not active, please contact the site admin."
+ return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ # otherwise
+ else:
+ '''
+ magic = "$1$"
+ password = password
+ # Generate a somewhat unique 8 character salt string
+ salt = str(time.time()) + str(Random().random())
+ salt = md5(salt).hexdigest()[:8]
+
+ if len(password) <= len(magic) or password[0:len(magic)] != magic:
+ password = crypt.crypt(password.encode('latin1'), magic + salt + "$")
+
+ user_params = {
+ 'email': username,
+ 'password': password
+ }
+ query = Query(action='create', object='local:user', params=user_params)
+
+
+ # Instantiate a TopHat router
+ with Router() as router:
+ router.forward(query)
+ '''
+ #myArgs=[username,password]
+ #os.spawnlp(os.P_WAIT,'/tmp/adduser.py', username, password, '/bin/bash/'i)
+ #command = '/var/www/manifold/manifold/bin/adduser.py ' + username + ' ' + password
+ #command = 'ls -la'
+ #args = shlex.split(command)
+ #p = subprocess.Popen(args, stdin=subprocess.PIPE).communicate()[0]
+ #print command
+ #print args
+ #print p
+ #env['state'] = "Now your CAFe user is associated to your MySlice account - Please logging in CAFe again."
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ user_params = { 'email': username, 'password': password }
+ manifold_add_user(request,user_params)
+
+ #query = Query().get('user').filter_by('email', '=', username).select('user_id')
+ #user = execute_admin_query(request,query)
+ #print "USER_ID:" + user
+ #user_id = user['user_id']
+ #user_id = user[0]
+ #print user_id
+ #splitmail = username.split("@")[0]
+ #user_params = { 'user': splitmail, 'platform': 'myslice' }
+ #user_params = { 'user_id': '2', 'platform_id': '2' }
+ #manifold_add_account(request,user_params)
+
+ # Ugly! Forcing the association of user and platform. This need to be automatic.
+ splitmail = username.split("@")[0]
+ user = splitmail.replace('"','').strip()
+ hrn = "fibrebr.dummy." + user
+ user_hrn = '{ "user_hrn": "'+ hrn +'" }'
+ #user_params = { 'config': user_hrn, 'auth_type': 'managed' }
+ user_params2 = { 'user_id': '2', 'platform_id': '2', 'config': user_hrn, 'auth_type': 'managed' }
+ manifold_add_account(request,user_params2)
+
+ ##user_id = '3'
+ #manifold_update_account(request,user_params)
+ html = "Now your CAFe user is associated with a MySlice account - Please login in CAFe again."
+ return HttpResponse(html)
+
+ # If we use ABAC - based on 'aff'
+ # else:
+ # #env['state'] = "Your affiliation (" + request.session["aff"] + ") at CAFe is not accepted."
+ # html = "Your CAFe affiliation (" + request.session["aff"] + ") is not accepted. <br> Only \"student\" affiliation."
+ # return HttpResponse(html)
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+
+
+ # login-ok sets state="Welcome to MySlice" in urls.py
+ def get (self, request, state=None):
+ env = self.default_env()
+ env['username']=the_user(request)
+ env['topmenu_items'] = topmenu_items(None, request)
+ if state: env['state'] = state
+ elif not env['username']: env['state'] = "Please sign in"
+ return HttpResponseRedirect ('/login-ok')
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
--- /dev/null
+#!/usr/bin/env python
+
+from portal.models import PendingUser
+#from portal.actions import create_pending_user
+# Edelberto - LDAP
+from portal.actions import create_pending_user, ldap_create_user
+
+#Edelberto from manifoldauth
+import os,sys
+import subprocess
+import shlex
+import getpass
+from hashlib import md5
+import time
+from random import randint
+import crypt
+
+import re
+#from manifold.manifold.core.router import Router
+from manifold.core.query import Query
+from manifoldapi.manifoldapi import execute_admin_query
+#from portal.actions import manifold_add_user, manifold_add_account, manifold_update_account
+from portal.actions import manifold_add_account, manifold_add_reference_user_accounts, sfa_create_user, create_pending_user
+from manifold.core.query import Query
+# add user to manifold
+
+from portal.models import PendingUser
+
+from django.views.generic import View
+from django.core.context_processors import csrf
+from django.contrib.auth import authenticate, login, logout
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+
+from manifold.manifoldresult import ManifoldResult
+from ui.topmenu import topmenu_items, the_user
+from myslice.configengine import ConfigEngine
+
+#from django.http import HttpResponse HttpResponseRedirect
+from django.http import HttpResponse
+#from django.http import HttpResponseRedirect
+#from django.template import RequestContext
+from django.contrib.sessions.backends.db import SessionStore
+
+def index(request):
+#class EdelbertoView (View):
+
+# XXX We use cookie!
+# Test cookie support
+ if request.session.test_cookie_worked():
+ #if session.test_cookie_worked():
+ return HttpResponse("Please enable cookies and try again.")
+ #return
+ print "Please enable cookies and try again."
+ else:
+ request.session['cn'] = request.META['Shib-inetOrgPerson-cn']
+ request.session['sn'] = request.META['Shib-inetOrgPerson-sn']
+ request.session['mail'] = request.META['Shib-inetOrgPerson-mail']
+ request.session['eppn'] = request.META['Shib-eduPerson-eduPersonPrincipalName']
+ #request.session['aff'] = request.META['Shib-brEduPerson-brEduAffiliationType']
+ request.session['aff'] = request.META['Shib-eduPerson-eduPersonAffiliation']
+ request.session['shib'] = request.META['Shib-Session-ID']
+
+ if 'mail' in request.session.keys():
+ print "Cookie: OK -> Content: cn:" + request.session["cn"] + " sn " +request.session["sn"] + " mail: " + request.session["mail"] + " eppn: " + request.session["eppn"]
+ #ip += "Cookie: OK -> Content: cn:" + request.session["cn"] + " mail: " + request.session["mail"] + " eppn: " + request.session["eppn"] + "</body></html>"
+ else:
+ print "Cookie: nothing/clear"
+ #ip += "Cookie: nothing/clear </body></html>"
+
+ # return HttpResponse(ip)
+
+
+ # XXX It's only to test the association of pi and esilva@uff.br
+ if request.session["eppn"] == 'esilva@uff.br':
+ username = 'rezende@ufrj'
+ password = 'fibre2014'
+ # pass request within the token, so manifold session key can be attached to the request session.
+ token = {'username': username, 'password': password, 'request': request}
+ # . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
+ # For all users - Verifying if he exists in MySlice/Manifold
+ else:
+ username = request.session["mail"]
+ # this is ugly. We generate a simple password merging mail "fibre" and sn.
+ password = request.session["mail"] + "fibre" + request.session["sn"]
+
+ # If we have " we remove
+ username = username.replace('"','').strip()
+ password = password.replace('"','').strip()
+
+ # pass request within the token, so manifold session key can be attached to the request session.
+ token = {'username': username, 'password': password, 'request': request}
+ # . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
+ # . a django User in case of success
+ # . or None if the backend could be reached but the authentication failed
+ auth_result = authenticate(token=token)
+ print auth_result
+ print token
+ # high-level errors, like connection refused or the like
+
+ if isinstance (auth_result, ManifoldResult):
+ manifoldresult = auth_result
+ htm = "<meta http-equiv=\"refresh\" content=\"0; url=https://sp-fibre.cafeexpresso.rnp.br/login-ok\" />"
+ return HttpResponse (htm)
+ # user was authenticated at the backend
+ elif auth_result is not None:
+ user=auth_result
+
+ # Verifying if user is active to logging in
+ if user.is_active:
+ print "LOGGING IN"
+ login(request, user)
+ htm = "<meta http-equiv=\"refresh\" content=\"0; url=https://sp-fibre.cafeexpresso.rnp.br/login-ok\" />"
+ #return HttpResponseRedirect ('/login-ok')
+ return HttpResponse (htm)
+ else:
+ # Today all CAFe accounts are actived
+ htm = "Your account is not active, please contact the site admin."
+ return HttpResponse (htm)
+
+
+ # otherwise
+ # Creating the user at manifold, myslice and sfa
+ else:
+ user_params = { 'email': username, 'password': password }
+ user_request = {}
+
+ user_request['auth_type'] = 'managed'
+
+ # XXX Common code, dependency ?
+ from Crypto.PublicKey import RSA
+ private = RSA.generate(1024)
+
+ # Example: private_key = '-----BEGIN RSA PRIVATE KEY-----\nMIIC...'
+ # Example: public_key = 'ssh-rsa AAAAB3...'
+ user_request['private_key'] = private.exportKey()
+ user_request['public_key'] = private.publickey().exportKey(format='OpenSSH')
+
+ splitmail = username.split("@")[0]
+ user = splitmail.replace('"','').strip()
+ hrn = "fibre." + user + str(randint(1,100000))
+
+ user_request['user_hrn'] = hrn
+
+ user_request['first_name'] = request.session['cn']
+ user_request['last_name'] = request.session['sn']
+ user_request['authority_hrn'] = "fibre"
+ user_request['email'] = username
+ user_request['password'] = password
+ user_request['public_key'] = user_request['public_key']
+ user_request['private_key'] = user_request['private_key']
+
+ # Verify in django
+ if PendingUser.objects.filter(email__iexact = user_request['email']):
+ htm = "Erro - User with same email from CAFe exists in Django"
+ # verify in manifol
+ user_query = Query().get('local:user').select('user_id','email')
+ user_details = execute_admin_query(request, user_query)
+ for user_detail in user_details:
+ if user_detail['email'] == user_request['email']:
+ htm = "Erro - user exist in SFA Registry"
+ try:
+ if user_detail['user_hrn'] == user_request['user_hrn']:
+ htm = "Erro - user with the same hrn in SFA Registry"
+ except:
+ continue
+
+
+ create_pending_user(user_request, user_request, user_detail)
+
+ return HttpResponse(htm)
+ return HttpResponse(htm)
--- /dev/null
+import time
+
+from django.contrib.auth.models import User
+
+from manifold.manifoldapi import ManifoldAPI, ManifoldException, ManifoldResult
+from manifold.core.query import Query
+
+# Name my backend 'ManifoldBackend'
+class ManifoldBackend:
+
+ # Create an authentication method
+ # This is called by the standard Django login procedure
+ def authenticate(self, token=None):
+ if not token:
+ return None
+
+ try:
+ username = token['username']
+ password = token['password']
+ request = token['request']
+
+ auth = {'AuthMethod': 'password', 'Username': username, 'AuthString': password}
+ api = ManifoldAPI(auth)
+ sessions_result = api.forward(Query.create('local:session').to_dict())
+ print "result"
+ sessions = sessions_result.ok_value()
+ print "ok"
+ if not sessions:
+ print "GetSession failed", sessions_result.error()
+ return
+ print "first", sessions
+ session = sessions[0]
+
+ # Change to session authentication
+ api.auth = {'AuthMethod': 'session', 'session': session['session']}
+ self.api = api
+
+ # Get account details
+ # the new API would expect Get('local:user') instead
+ persons_result = api.forward(Query.get('local:user').to_dict())
+ persons = persons_result.ok_value()
+ if not persons:
+ print "GetPersons failed",persons_result.error()
+ return
+ person = persons[0]
+ print "PERSON=", person
+
+ request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': session['expires']}
+ except ManifoldException, e:
+ print "Caught ManifoldException, returning corresponding ManifoldResult"
+ return e.manifold_result
+ except Exception, e:
+ print "E: manifoldbackend", e
+ import traceback
+ traceback.print_exc()
+ return None
+
+ try:
+ # Check if the user exists in Django's local database
+ user = User.objects.get(username=username)
+ except User.DoesNotExist:
+ # Create a user in Django's local database
+ user = User.objects.create_user(username, username, 'passworddoesntmatter')
+ user.first_name = "DUMMY_FIRST_NAME" #person['first_name']
+ user.last_name = "DUMMY LAST NAME" # person['last_name']
+ user.email = person['email']
+ return user
+
+ # Required for your backend to work properly - unchanged in most scenarios
+ def get_user(self, user_id):
+ try:
+ return User.objects.get(pk=user_id)
+ except User.DoesNotExist:
+ return None
+
+
--- /dev/null
+#!/usr/bin/env python
+
+#Edelberto from manifoldauth
+import os,sys
+import subprocess
+import shlex
+import getpass
+from hashlib import md5
+import time
+from random import Random
+import crypt
+
+import re
+#from manifold.manifold.core.router import Router
+from manifold.core.query import Query
+from manifold.manifoldapi import execute_admin_query
+from portal.actions import manifold_add_user, manifold_add_account, manifold_update_account
+from manifold.core.query import Query
+# add user to manifold
+
+from django.views.generic import View
+from django.core.context_processors import csrf
+#from django.http import HttpResponseRedirect
+from django.contrib.auth import authenticate, login, logout
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+
+from manifold.manifoldresult import ManifoldResult
+from ui.topmenu import topmenu_items, the_user
+from myslice.config import Config
+
+#from django.http import HttpResponse HttpResponseRedirect
+from django.http import HttpResponse
+#from django.http import HttpResponseRedirect
+#from django.template import RequestContext
+from django.contrib.sessions.backends.db import SessionStore
+
+def index(request):
+#class EdelbertoView (View):
+
+# =================== Old code - to validate =================
+ '''
+ ip = "<html><body>"
+ ip += "cn: " + request.META['Shib-inetOrgPerson-cn'] + "</br>"
+ ip += "sn: " + request.META['Shib-inetOrgPerson-sn'] + "</br>"
+ ip += "eppn: " + request.META['Shib-eduPerson-eduPersonPrincipalName'] + "</br>"
+ ip += "mail: " + request.META['Shib-inetOrgPerson-mail'] + "</br>"
+ ip += "Affiliation br: " + request.META['Shib-brEduPerson-brEduAffiliationType'] + "</br>"
+ ip += "Affiliation edu: " + request.META['Shib-eduPerson-eduPersonAffiliation'] + "</br>"
+ ip += "Auth-Method: " + request.META['Shib-Authentication-Method'] + "</br>"
+ ip += "Identity Provider: " + request.META['Shib-Identity-Provider'] + "</br>"
+ ip += "Application ID: " + request.META['Shib-Application-ID'] + "</br>"
+ ip += "Session ID: " + request.META['Shib-Session-ID'] + "</br>"
+ '''
+# Test cookie support
+ if request.session.test_cookie_worked():
+ #if session.test_cookie_worked():
+ return HttpResponse("Please enable cookies and try again.")
+ #return
+ print "Please enable cookies and try again."
+ else:
+ request.session['cn'] = request.META['Shib-inetOrgPerson-cn']
+ request.session['mail'] = request.META['Shib-inetOrgPerson-mail']
+ request.session['eppn'] = request.META['Shib-eduPerson-eduPersonPrincipalName']
+ #request.session['aff'] = request.META['Shib-brEduPerson-brEduAffiliationType']
+ request.session['aff'] = request.META['Shib-eduPerson-eduPersonAffiliation']
+ request.session['shib'] = request.META['Shib-Session-ID']
+
+ if 'mail' in request.session.keys():
+ print "Cookie: OK -> Content: cn:" + request.session["cn"] + " mail: " + request.session["mail"] + " eppn: " + request.session["eppn"]
+ #ip += "Cookie: OK -> Content: cn:" + request.session["cn"] + " mail: " + request.session["mail"] + " eppn: " + request.session["eppn"] + "</body></html>"
+ else:
+ print "Cookie: nothing/clear"
+ #ip += "Cookie: nothing/clear </body></html>"
+
+ # return HttpResponse(ip)
+
+
+ # expose this so we can mention the backend URL on the welcome page
+ def default_env (self):
+ config=Config()
+ return {
+ 'MANIFOLD_URL':config.manifold_url(),
+ }
+
+ #def post (self,request):
+ # env = self.default_env()
+ #username = request.POST.get('username')
+ #password = request.POST.get('password')
+ if 'aff' in request.session.keys():
+ aff = request.session["aff"]
+ if aff == "student":
+ if request.session["eppn"] == 'esilva@uff.br':
+ username = 'admin'
+ password = 'fibre2013'
+ else:
+ username = request.session["mail"]
+ password = request.session["mail"] + "fibre2013"
+ username = username.replace('"','').strip()
+ password = password.replace('"','').strip()
+ # pass request within the token, so manifold session key can be attached to the request session.
+ token = {'username': username, 'password': password, 'request': request}
+
+ # our authenticate function returns either
+ # . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
+ # . a django User in case of success
+ # . or None if the backend could be reached but the authentication failed
+ auth_result = authenticate(token=token)
+ # high-level errors, like connection refused or the like
+ if isinstance (auth_result, ManifoldResult):
+ manifoldresult = auth_result
+ # let's use ManifoldResult.__repr__
+ env['state']="%s"%manifoldresult
+ return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ # user was authenticated at the backend
+ elif auth_result is not None:
+ user=auth_result
+ if user.is_active:
+ print "LOGGING IN"
+ login(request, user)
+ htm = "<meta http-equiv=\"refresh\" content=\"0; url=https://sp-php.cafeexpresso.rnp.br/login-ok\" />"
+ #return HttpResponseRedirect ('/login-ok')
+ return HttpResponse (htm)
+ else:
+ env['state'] = "Your account is not active, please contact the site admin."
+ return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ # otherwise
+ else:
+ '''
+ magic = "$1$"
+ password = password
+ # Generate a somewhat unique 8 character salt string
+ salt = str(time.time()) + str(Random().random())
+ salt = md5(salt).hexdigest()[:8]
+
+ if len(password) <= len(magic) or password[0:len(magic)] != magic:
+ password = crypt.crypt(password.encode('latin1'), magic + salt + "$")
+
+ user_params = {
+ 'email': username,
+ 'password': password
+ }
+ query = Query(action='create', object='local:user', params=user_params)
+
+
+ # Instantiate a TopHat router
+ with Router() as router:
+ router.forward(query)
+ '''
+ #myArgs=[username,password]
+ #os.spawnlp(os.P_WAIT,'/tmp/adduser.py', username, password, '/bin/bash/'i)
+ #command = '/var/www/manifold/manifold/bin/adduser.py ' + username + ' ' + password
+ #command = 'ls -la'
+ #args = shlex.split(command)
+ #p = subprocess.Popen(args, stdin=subprocess.PIPE).communicate()[0]
+ #print command
+ #print args
+ #print p
+ #env['state'] = "Now your CAFe user is associated to your MySlice account - Please logging in CAFe again."
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ user_params = { 'email': username, 'password': password }
+ manifold_add_user(request,user_params)
+
+ #query = Query().get('user').filter_by('email', '=', username).select('user_id')
+ #user = execute_admin_query(request,query)
+ #print "USER_ID:" + user
+ #user_id = user['user_id']
+ #user_id = user[0]
+ #print user_id
+ #splitmail = username.split("@")[0]
+ #user_params = { 'user': splitmail, 'platform': 'myslice' }
+ user_params = { 'user_id': '3', 'platform_id': '2' }
+ manifold_add_account(request,user_params)
+
+ splitmail = username.split("@")[0]
+ user_hrn = '{"user_hrn": "fibrebr.dummy."'+ splitmail + '"}'
+ user_params = { 'config': user_hrn, 'auth_type':'managed'}
+ manifold_update_account(request,user_params)
+ html = "Now your CAFe user is associated with a MySlice account - Please login in CAFe again."
+ return HttpResponse(html)
+
+ else:
+ #env['state'] = "Your affiliation (" + request.session["aff"] + ") at CAFe is not accepted."
+ html = "Your CAFe affiliation (" + request.session["aff"] + ") is not accepted. <br> Only \"student\" affiliation."
+ return HttpResponse(html)
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+
+
+ # login-ok sets state="Welcome to MySlice" in urls.py
+ def get (self, request, state=None):
+ env = self.default_env()
+ env['username']=the_user(request)
+ env['topmenu_items'] = topmenu_items(None, request)
+ if state: env['state'] = state
+ elif not env['username']: env['state'] = "Please sign in"
+ return HttpResponseRedirect ('/login-ok')
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
--- /dev/null
+#!/usr/bin/env python
+
+#Edelberto from manifoldauth
+import os,sys
+import subprocess
+import shlex
+import getpass
+from hashlib import md5
+import time
+from random import Random
+import crypt
+
+#from manifold.manifold.core.router import Router
+from manifold.core.query import Query
+# add user to manifold
+
+from django.views.generic import View
+from django.core.context_processors import csrf
+#from django.http import HttpResponseRedirect
+from django.contrib.auth import authenticate, login, logout
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+
+from manifold.manifoldresult import ManifoldResult
+from ui.topmenu import topmenu_items, the_user
+from myslice.config import Config
+
+#from django.http import HttpResponse HttpResponseRedirect
+from django.http import HttpResponse
+#from django.http import HttpResponseRedirect
+#from django.template import RequestContext
+from django.contrib.sessions.backends.db import SessionStore
+
+def index(request):
+#class EdelbertoView (View):
+
+# =================== Old code - to validate =================
+ '''
+ ip = "<html><body>"
+ ip += "cn: " + request.META['Shib-inetOrgPerson-cn'] + "</br>"
+ ip += "sn: " + request.META['Shib-inetOrgPerson-sn'] + "</br>"
+ ip += "eppn: " + request.META['Shib-eduPerson-eduPersonPrincipalName'] + "</br>"
+ ip += "mail: " + request.META['Shib-inetOrgPerson-mail'] + "</br>"
+ ip += "Affiliation br: " + request.META['Shib-brEduPerson-brEduAffiliationType'] + "</br>"
+ ip += "Affiliation edu: " + request.META['Shib-eduPerson-eduPersonAffiliation'] + "</br>"
+ ip += "Auth-Method: " + request.META['Shib-Authentication-Method'] + "</br>"
+ ip += "Identity Provider: " + request.META['Shib-Identity-Provider'] + "</br>"
+ ip += "Application ID: " + request.META['Shib-Application-ID'] + "</br>"
+ ip += "Session ID: " + request.META['Shib-Session-ID'] + "</br>"
+ '''
+# Test cookie support
+ if request.session.test_cookie_worked():
+ #if session.test_cookie_worked():
+ return HttpResponse("Please enable cookies and try again.")
+ #return
+ print "Please enable cookies and try again."
+ else:
+ request.session['cn'] = request.META['Shib-inetOrgPerson-cn']
+ request.session['mail'] = request.META['Shib-inetOrgPerson-mail']
+ request.session['eppn'] = request.META['Shib-eduPerson-eduPersonPrincipalName']
+ #request.session['aff'] = request.META['Shib-brEduPerson-brEduAffiliationType']
+ request.session['aff'] = request.META['Shib-eduPerson-eduPersonAffiliation']
+ request.session['shib'] = request.META['Shib-Session-ID']
+
+ if 'mail' in request.session.keys():
+ print "Cookie: OK -> Content: cn:" + request.session["cn"] + " mail: " + request.session["mail"] + " eppn: " + request.session["eppn"]
+ #ip += "Cookie: OK -> Content: cn:" + request.session["cn"] + " mail: " + request.session["mail"] + " eppn: " + request.session["eppn"] + "</body></html>"
+ else:
+ print "Cookie: nothing/clear"
+ #ip += "Cookie: nothing/clear </body></html>"
+
+ # return HttpResponse(ip)
+
+
+ # expose this so we can mention the backend URL on the welcome page
+ def default_env (self):
+ config=Config()
+ return {
+ 'MANIFOLD_URL':config.manifold_url(),
+ }
+
+ #def post (self,request):
+ # env = self.default_env()
+ #username = request.POST.get('username')
+ #password = request.POST.get('password')
+ if 'aff' in request.session.keys():
+ aff = request.session["aff"]
+ if aff == "student":
+ if request.session["eppn"] == 'esilva@uff.br':
+ username = 'admin'
+ password = 'fibre2013'
+ else:
+ username = request.session["mail"]
+ password = request.session["mail"] + "fibre2013"
+
+ # pass request within the token, so manifold session key can be attached to the request session.
+ token = {'username': username, 'password': password, 'request': request}
+
+ # our authenticate function returns either
+ # . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
+ # . a django User in case of success
+ # . or None if the backend could be reached but the authentication failed
+ auth_result = authenticate(token=token)
+ # high-level errors, like connection refused or the like
+ if isinstance (auth_result, ManifoldResult):
+ manifoldresult = auth_result
+ # let's use ManifoldResult.__repr__
+ env['state']="%s"%manifoldresult
+ return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ # user was authenticated at the backend
+ elif auth_result is not None:
+ user=auth_result
+ if user.is_active:
+ print "LOGGING IN"
+ login(request, user)
+ htm = "<meta http-equiv=\"refresh\" content=\"0; url=https://sp-php.cafeexpresso.rnp.br/login-ok\" />"
+ #return HttpResponseRedirect ('/login-ok')
+ return HttpResponse (htm)
+ else:
+ env['state'] = "Your account is not active, please contact the site admin."
+ return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ # otherwise
+ else:
+ '''
+ magic = "$1$"
+ password = password
+ # Generate a somewhat unique 8 character salt string
+ salt = str(time.time()) + str(Random().random())
+ salt = md5(salt).hexdigest()[:8]
+
+ if len(password) <= len(magic) or password[0:len(magic)] != magic:
+ password = crypt.crypt(password.encode('latin1'), magic + salt + "$")
+
+ user_params = {
+ 'email': username,
+ 'password': password
+ }
+ query = Query(action='create', object='local:user', params=user_params)
+
+
+ # Instantiate a TopHat router
+ with Router() as router:
+ router.forward(query)
+ '''
+ #myArgs=[username,password]
+ #os.spawnlp(os.P_WAIT,'/tmp/adduser.py', username, password, '/bin/bash/')
+ command = '/var/www/manifold/manifold/bin/adduser.py ' + username + ' ' + password
+ #command = 'ls -la'
+ args = shlex.split(command)
+ p = subprocess.Popen(args, stdin=subprocess.PIPE).communicate()[0]
+ print command
+ print args
+ print p
+ #env['state'] = "Now your CAFe user is associated to your MySlice account - Please logging in CAFe again."
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+ html = "Now its CAFe user is associated with a MySlice account - Please login in CAFe again."
+ return HttpResponse(html)
+
+ else:
+ #env['state'] = "Your affiliation (" + request.session["aff"] + ") at CAFe is not accepted."
+ html = "Your CAFe affiliation (" + request.session["aff"] + ") is not accepted. <br> Only \"student\" affiliation."
+ return HttpResponse(html)
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
+
+
+ # login-ok sets state="Welcome to MySlice" in urls.py
+ def get (self, request, state=None):
+ env = self.default_env()
+ env['username']=the_user(request)
+ env['topmenu_items'] = topmenu_items(None, request)
+ if state: env['state'] = state
+ elif not env['username']: env['state'] = "Please sign in"
+ return HttpResponseRedirect ('/login-ok')
+ #return render_to_response('home-view.html',env, context_instance=RequestContext(request))
--- /dev/null
+from django.core.urlresolvers import reverse\r
+from urllib import quote\r
+\r
+from django.conf import settings\r
+import myslice.settings\r
+\r
+def login_link(request):\r
+ """\r
+ This assumes your login link is the Shibboleth login page for your server \r
+ and uses the 'target' url parameter.\r
+ """\r
+ full_path = quote(request.get_full_path())\r
+ #login = reverse('shibboleth:login')\r
+\r
+ LOGIN_URL = getattr(settings, 'LOGIN_URL', None)\r
+\r
+ login = LOGIN_URL\r
+ ll = "%s?target=%s" % (login, full_path)\r
+ return { 'login_link': ll }\r
+\r
+def logout_link(request, *args):\r
+ """\r
+ This assumes your login link is the Shibboleth login page for your server \r
+ and uses the 'target' url parameter.\r
+ e.g: https://sp-php.cafeexpresso.rnp.br/Shibboleth.sso/Login\r
+ """\r
+ from app_settings import LOGOUT_URL, LOGOUT_REDIRECT_URL\r
+ #LOGOUT_REDIRECT_URL specifies a default logout page that will always be used when\r
+ #users logout from Shibboleth.\r
+ target = LOGOUT_REDIRECT_URL or quote(request.build_absolute_uri())\r
+ logout = reverse('shibboleth:logout')\r
+ ll = "%s?target=%s" % (logout, target)\r
+ return { 'logout_link': ll }\r
--- /dev/null
+import time
+
+from django.contrib.auth.models import User
+
+from manifold.manifoldapi import ManifoldAPI, ManifoldException, ManifoldResult
+from manifold.core.query import Query
+
+# Name my backend 'ManifoldBackend'
+class ManifoldBackend:
+
+ # Create an authentication method
+ # This is called by the standard Django login procedure
+ def authenticate(self, token=None):
+ if not token:
+ return None
+
+ try:
+ username = token['username']
+ password = token['password']
+ request = token['request']
+
+ auth = {'AuthMethod': 'password', 'Username': username, 'AuthString': password}
+ api = ManifoldAPI(auth)
+ sessions_result = api.forward(Query.create('local:session').to_dict())
+ print "result"
+ sessions = sessions_result.ok_value()
+ print "ok"
+ if not sessions:
+ print "GetSession failed", sessions_result.error()
+ return
+ print "first", sessions
+ session = sessions[0]
+
+ # Change to session authentication
+ api.auth = {'AuthMethod': 'session', 'session': session['session']}
+ self.api = api
+
+ # Get account details
+ # the new API would expect Get('local:user') instead
+ persons_result = api.forward(Query.get('local:user').to_dict())
+ persons = persons_result.ok_value()
+ if not persons:
+ print "GetPersons failed",persons_result.error()
+ return
+ person = persons[0]
+ print "PERSON=", person
+
+ request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': session['expires']}
+ except ManifoldException, e:
+ print "Caught ManifoldException, returning corresponding ManifoldResult"
+ return e.manifold_result
+ except Exception, e:
+ print "E: manifoldbackend", e
+ import traceback
+ traceback.print_exc()
+ return None
+
+ try:
+ # Check if the user exists in Django's local database
+ user = User.objects.get(username=username)
+ except User.DoesNotExist:
+ # Create a user in Django's local database
+ user = User.objects.create_user(username, username, 'passworddoesntmatter')
+ user.first_name = "DUMMY_FIRST_NAME" #person['first_name']
+ user.last_name = "DUMMY LAST NAME" # person['last_name']
+ user.email = person['email']
+ return user
+
+ # Required for your backend to work properly - unchanged in most scenarios
+ def get_user(self, user_id):
+ try:
+ return User.objects.get(pk=user_id)
+ except User.DoesNotExist:
+ return None
+
+
--- /dev/null
+#!/usr/bin/env python
+
+#Edelberto from manifoldauth
+import os,sys
+import subprocess
+import shlex
+import getpass
+from hashlib import md5
+import time
+from random import Random
+import crypt
+
+username = 'teste'
+password = '123'
+
+command = '/var/www/manifold/manifold/bin/adduser.py ' + username + ' ' + password
+ #command = 'ls -la'
+args = shlex.split(command)
+p = subprocess.Popen(args, stdin=subprocess.PIPE).communicate()[0]
+print command
+print args
+print p
--- /dev/null
+#!/usr/bin/env python
+
+#Edelberto from manifoldauth
+import os,sys
+import subprocess
+import shlex
+import getpass
+from hashlib import md5
+import time
+from random import Random
+import crypt
+
+username = 'teste'
+password = '123'
+
+command = '/var/www/manifold/manifold/bin/adduser.py ' + username + ' ' + password
+ #command = 'ls -la'
+args = shlex.split(command)
+p = subprocess.Popen(args, stdin=subprocess.PIPE).communicate()[0]
+print command
+print args
+print p
--- /dev/null
+from django.http import HttpResponse
+from manifold.core.query import Query
+from manifoldapi.manifoldapi import execute_query,execute_admin_query
+from portal.models import PendingUser, PendingSlice, PendingAuthority
+import json
+
+from django.contrib.auth.models import User
+from django.template.loader import render_to_string
+from django.core.mail import EmailMultiAlternatives
+
+from theme import ThemeView
+
+theme = ThemeView()
+
+# Thierry: moving this right into the code so
+# most people can use myslice without having to install sfa
+# XXX tmp sfa dependency, should be moved to SFA gateway
+#from sfa.util.xrn import Xrn
+
+
+# Get the list of authorities
+
+def authority_get_pis(request, authority_hrn):
+ query = Query.get('authority').filter_by('authority_hrn', '==', authority_hrn).select('pi_users')
+ results = execute_admin_query(request, query)
+ # NOTE: temporarily commented. Because results is giving empty list.
+ # Needs more debugging
+ #if not results:
+ # raise Exception, "Authority not found: %s" % authority_hrn
+ #result, = results
+ #return result['pi_users']
+ return results
+
+def authority_get_pi_emails(request, authority_hrn):
+ pi_users = authority_get_pis(request,authority_hrn)
+ if any(d['pi_users'] == None for d in pi_users):
+ theme.template_name = 'email_default_recipients.txt'
+ default_email = render_to_string(theme.template, request)
+ default_email = default_email.replace('\n', '')
+ return default_email
+ else:
+ pi_user_hrns = [ hrn for x in pi_users for hrn in x['pi_users'] ]
+ query = Query.get('user').filter_by('user_hrn', 'included', pi_user_hrns).select('user_email')
+ results = execute_admin_query(request, query)
+ return [result['user_email'] for result in results]
+
+def is_pi(wsgi_request, user_hrn, authority_hrn):
+ # XXX could be done in a single query !
+
+ # select pi_authorities from user where user_hrn == "ple.upmc.jordan_auge"
+ query = Query.get('user').filter_by('user_hrn', '==', user_hrn).select('pi_authorities')
+ results = execute_admin_query(wsgi_request, query)
+ if not results:
+ # XXX Warning ?
+ return False
+ result = results[0]
+ user_authority_hrns = result.get('pi_authorities', [])
+ return authority_hrn in user_authority_hrns
+
+# SFA get record
+
+def sfa_get_user(request, user_hrn, pub):
+ query_sfa_user = Query.get('user').filter_by('user_hrn', '==', user_hrn)
+ result_sfa_user = execute_query(request, query_sfa_user)
+ return result_sfa_user
+
+def sfa_update_user(request, user_hrn, user_params):
+ # user_params: keys [public_key]
+ if 'email' in user_params:
+ user_params['user_email'] = user_params['email']
+ query = Query.update('user').filter_by('user_hrn', '==', user_hrn).set(user_params).select('user_hrn')
+ results = execute_query(request,query)
+ return results
+
+def sfa_add_authority(request, authority_params):
+ query = Query.create('authority').set(authority_params).select('authority_hrn')
+ results = execute_query(request, query)
+ print "sfa_add_auth results=",results
+ if not results:
+ raise Exception, "Could not create %s. Already exists ?" % authority_params['hrn']
+ return results
+
+def sfa_add_user_to_slice(request, user_hrn, slice_params):
+# UPDATE myslice:slice SET researcher=['ple.upmc.jordan_auge','ple.inria.thierry_parmentelat','ple.upmc.loic_baron','ple.upmc.ciro_scognamiglio','ple.upmc.mohammed-yasin_rahman','ple.upmc.azerty'] where slice_hrn=='ple.upmc.myslicedemo'
+ query_current_users = Query.get('slice').select('user').filter_by('slice_hrn','==',slice_params['hrn'])
+ results_current_users = execute_query(request, query_current_users)
+ slice_params['researcher'] = slice_params['researcher'] | results_current_users
+ query = Query.update('slice').filter_by('user_hrn', '==', user_hrn).set(slice_params).select('slice_hrn')
+ results = execute_query(request, query)
+# Also possible but not supported yet
+# UPDATE myslice:user SET slice=['ple.upmc.agent','ple.upmc.myslicedemo','ple.upmc.tophat'] where user_hrn=='ple.upmc.azerty'
+ if not results:
+ raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
+ return results
+
+# Propose hrn
+
+def manifold_add_user(wsgi_request, request):
+ """Add a Manifold user corresponding to a user request.
+
+ Args:
+ wsgi_request: a WSGIRequest instance
+ request (dict): a dictionary containing the user request built from the
+ form.
+
+ Returns:
+ The user_id of the inserted user.
+
+ Raises:
+ ?
+
+ """
+ USER_CONFIG = '{"firstname": "%(first_name)s", "lastname": "%(last_name)s", "authority": "%(authority_hrn)s"}'
+
+ user_params = {
+ 'email' : request['email'],
+ 'password' : request['password'],
+ 'config' : USER_CONFIG % request,
+ 'status' : 1,
+ }
+
+ query = Query.create('local:user').set(user_params).select('email')
+ results = execute_admin_query(request, query)
+ if not results:
+ raise Exception, "Failed creating manifold user: %s" % user_params['email']
+ result = results[0]
+ return result['email']
+
+def manifold_update_user(request, email, user_params):
+ # user_params: password, config e.g.,
+ query = Query.update('local:user').filter_by('email', '==', email).set(user_params).select('email')
+ results = execute_admin_query(request,query)
+ # NOTE: results remains empty and goes to Exception. However, it updates the manifold DB.
+ # That's why I commented the exception part. -- Yasin
+ #if not results:
+ # raise Exception, "Failed updating manifold user: %s" % user_params['email']
+ #result, = results
+ return results
+
+def manifold_add_account(request, account_params):
+ query = Query.create('local:account').set(account_params).select(['user', 'platform'])
+ results = execute_admin_query(request,query)
+ if not results:
+ raise Exception, "Failed creating manifold account on platform %s for user: %s" % (account_params['platform'], account_params['user'])
+ result, = results
+ return result['user_id']
+
+def manifold_update_account(request,user_id,account_params):
+ # account_params: config
+ query = Query.update('local:account').filter_by('platform', '==', 'myslice').filter_by('user_id', '==', user_id).set(account_params).select('user_id')
+ results = execute_admin_query(request,query)
+ return results
+
+#explicitly mention the platform_id
+def manifold_delete_account(request, platform_id, user_id, account_params):
+ query = Query.delete('local:account').filter_by('platform_id', '==', platform_id).filter_by('user_id', '==', user_id).set(account_params).select('user_id')
+ results = execute_admin_query(request,query)
+ return results
+
+
+#not tested
+def manifold_add_platform(request, platform_params):
+ query = Query.create('local:platform').set(platform_params).select(['user', 'platform'])
+ results = execute_admin_query(request,query)
+ if not results:
+ raise Exception, "Failed creating manifold platform %s for user: %s" % (platform_params['platform'], platform_params['user'])
+ result, = results
+ return result['platform_id']
+
+
+def make_request_user(user):
+ request = {}
+ request['type'] = 'user'
+ request['id'] = user.id
+ request['timestamp'] = user.created # XXX in DB ?
+ request['authority_hrn'] = user.authority_hrn
+ request['first_name'] = user.first_name
+ request['last_name'] = user.last_name
+ request['email'] = user.email
+ request['login'] = user.login
+ request['user_hrn'] = user.user_hrn
+ request['public_key'] = user.public_key
+ request['private_key'] = user.private_key
+ return request
+
+def make_request_slice(slice):
+ request = {}
+ request['type'] = 'slice'
+ request['id'] = slice.id
+ request['user_hrn'] = slice.user_hrn
+ request['timestamp'] = slice.created
+ request['authority_hrn'] = slice.authority_hrn
+ request['slice_name'] = slice.slice_name
+ request['number_of_nodes'] = slice.number_of_nodes
+ request['type_of_nodes'] = slice.type_of_nodes
+ request['purpose'] = slice.purpose
+ return request
+
+def make_request_authority(authority):
+ request = {}
+ request['type'] = 'authority'
+ request['id'] = authority.id
+ request['site_name'] = authority.site_name
+ request['site_latitude'] = authority.site_latitude
+ request['site_longitude'] = authority.site_longitude
+ request['site_url'] = authority.site_url
+ request['site_authority'] = authority.site_authority
+ request['site_abbreviated_name'] = authority.site_abbreviated_name
+ request['address_line1'] = authority.address_line1
+ request['address_line2'] = authority.address_line2
+ request['address_line3'] = authority.address_line3
+ request['address_city'] = authority.address_city
+ request['address_postalcode'] = authority.address_postalcode
+ request['address_state'] = authority.address_state
+ request['address_country'] = authority.address_country
+ request['authority_hrn'] = authority.authority_hrn
+ request['timestamp'] = authority.created
+ return request
+
+def make_requests(pending_users, pending_slices, pending_authorities):
+ requests = []
+ for user in pending_users:
+ requests.append(make_request_user(user))
+ for slice in pending_slices:
+ requests.append(make_request_slice(slice))
+ for authority in pending_authorities:
+ requests.append(make_request_authority(authority))
+ return requests
+
+def get_request_by_id(ids):
+ sorted_ids = { 'user': [], 'slice': [], 'authority': [] }
+ for type__id in ids:
+ type, id = type__id.split('__')
+ sorted_ids[type].append(id)
+
+ if not ids:
+ pending_users = PendingUser.objects.all()
+ pending_slices = PendingSlice.objects.all()
+ pending_authorities = PendingAuthority.objects.all()
+ else:
+ pending_users = PendingUser.objects.filter(id__in=sorted_ids['user']).all()
+ pending_slices = PendingSlice.objects.filter(id__in=sorted_ids['slice']).all()
+ pending_authorities = PendingAuthority.objects.filter(id__in=sorted_ids['authority']).all()
+
+ return make_requests(pending_users, pending_slices, pending_authorities)
+
+def get_requests(authority_hrns=None):
+ print "get_request_by_authority auth_hrns = ", authority_hrns
+ if not authority_hrns:
+ pending_users = PendingUser.objects.all()
+ pending_slices = PendingSlice.objects.all()
+ pending_authorities = PendingAuthority.objects.all()
+ else:
+ pending_users = PendingUser.objects.filter(authority_hrn__in=authority_hrns).all()
+ pending_slices = PendingSlice.objects.filter(authority_hrn__in=authority_hrns).all()
+ pending_authorities = PendingAuthority.objects.filter(authority_hrn__in=authority_hrns).all()
+
+ return make_requests(pending_users, pending_slices, pending_authorities)
+
+# XXX Is it in sync with the form fields ?
+
+def portal_validate_request(wsgi_request, request_ids):
+ status = {}
+
+ if not isinstance(request_ids, list):
+ request_ids = [request_ids]
+
+ requests = get_request_by_id(request_ids)
+ for request in requests:
+ # type, id, timestamp, details, allowed -- MISSING: authority_hrn
+ # CAREFUL about details
+ # user : first name, last name, email, password, keypair
+ # slice : number of nodes, type of nodes, purpose
+
+ request_status = {}
+
+ if request['type'] == 'user':
+
+ try:
+ create_user(wsgi_request, request)
+ request_status['SFA user'] = {'status': True }
+
+ except Exception, e:
+ request_status['SFA user'] = {'status': False, 'description': str(e)}
+
+# user_params = {'status':2}
+# manifold_update_user(request, request['email'], user_params)
+
+ # MANIFOLD user should be added beforehand, during registration
+ #try:
+ # manifold_user_params = { key: request[key] for key in MANIFOLD_USER_KEYS }
+ # # XXX # manifold_add_user(manifold_user_params)
+ # request_status['MySlice user'] = {'status': True }
+ #except Exception, e:
+ # request_status['MySlice user'] = {'status': False, 'description': str(e)}
+
+ # XXX
+ #manifold_account_params = { key: request[key] for key in MANIFOLD_ACCOUNT_KEYS }
+ #manifold_add_account(manifold_account_params)
+ #request_status['MySlice testbed accounts'] = {'status': False }
+
+ elif request['type'] == 'slice':
+ try:
+ create_slice(wsgi_request, request)
+ request_status['SFA slice'] = {'status': True }
+
+ except Exception, e:
+ request_status['SFA slice'] = {'status': False, 'description': str(e)}
+
+ elif request['type'] == 'authority':
+ try:
+ #hrn = "%s.%s" % (request['authority_hrn'], request['site_authority'])
+ hrn = request['site_authority']
+ # XXX tmp sfa dependency
+ from sfa.util.xrn import Xrn
+ urn = Xrn(hrn, request['type']).get_urn()
+
+ sfa_authority_params = {
+ 'hrn' : hrn,
+ 'urn' : urn,
+ 'type' : request['type'],
+ #'pi' : None,
+ 'enabled' : True
+ }
+ print "ADD Authority"
+ sfa_add_authority(wsgi_request, sfa_authority_params)
+ request_status['SFA authority'] = {'status': True }
+
+ except Exception, e:
+ request_status['SFA authority'] = {'status': False, 'description': str(e)}
+
+ # XXX Remove from Pendings in database
+
+ status['%s__%s' % (request['type'], request['id'])] = request_status
+
+ return status
+
+
+def validate_action(request, **kwargs):
+ ids = filter(None, kwargs['id'].split('/'))
+ status = portal_validate_request(request, ids)
+ json_answer = json.dumps(status)
+ return HttpResponse (json_answer, mimetype="application/json")
+
+# Django and ajax
+# http://djangosnippets.org/snippets/942/
+
+
+
+#-------------------------------------------------------------------------------
+# REQUESTS - Slices
+#-------------------------------------------------------------------------------
+
+def create_slice(wsgi_request, request):
+ """
+ Arguments:
+ wsgi_request (~ WSGIRequest) :
+ request (dict) : the slice request in our own dict format
+
+ Raises:
+ Exception
+ """
+ hrn = "%s.%s" % (request['authority_hrn'], request['slice_name'])
+ # XXX tmp sfa dependency
+ from sfa.util.xrn import Xrn
+ urn = Xrn(hrn, request['type']).get_urn()
+
+ # Add User to Slice if we have the user_hrn in pendingslice table
+ user_hrn = request.get('user_hrn', None)
+ user_hrns = list([user_hrn]) if user_hrn else list()
+
+ # XXX We should create a slice with Manifold terminology
+ slice_params = {
+ 'slice_hrn' : hrn,
+ 'slice_urn' : urn,
+ 'slice_type' : request['type'],
+ 'users' : user_hrns,
+ 'slice_enabled' : True
+ }
+ # ignored in request: id, timestamp, number_of_nodes, type_of_nodes, purpose
+
+ query = Query.create('slice').set(slice_params).select('slice_hrn')
+ results = execute_query(wsgi_request, query)
+ if not results:
+ raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
+ return results
+
+def create_pending_slice(wsgi_request, request, email):
+ """
+ """
+
+ # Insert an entry in the PendingSlice table
+ s = PendingSlice(
+ slice_name = request['slice_name'],
+ user_hrn = request['user_hrn'],
+ authority_hrn = request['authority_hrn'],
+ number_of_nodes = request['number_of_nodes'],
+ purpose = request['purpose'],
+ )
+ s.save()
+
+ try:
+ # Send an email: the recipients are the PI of the authority
+ recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
+
+ theme.template_name = 'slice_request_email.txt'
+ text_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'slice_request_email.html'
+ html_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'slice_request_email_subject.txt'
+ subject = render_to_string(theme.template, request)
+ subject = subject.replace('\n', '')
+
+ sender = email
+ msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+ print msg
+ msg.attach_alternative(html_content, "text/html")
+ msg.send()
+ except Exception, e:
+ print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+
+#-------------------------------------------------------------------------------
+# REQUESTS - Users
+#-------------------------------------------------------------------------------
+
+def manifold_add_reference_user_accounts(wsgi_request, request):
+ """When a new user is created, add reference accounts to the reference platform.
+ """
+ # XXX XXX XXX The rest of this function has to be checked XXX XXX XXX
+
+ # Retrieve user information
+ user_query = Query().get('local:user') \
+ .select('user_id', 'config', 'email', 'status') \
+ .filter_by('email', '==', request['email'])
+ user_details = execute_admin_query(wsgi_request, user_query)
+
+ # USER MAIN ACCOUNT != reference
+ #print 'USER MAIN ACCOUNT != reference'
+ list_accounts_query = Query().get('local:account') \
+ .select('user_id', 'platform_id', 'auth_type', 'config') \
+ .filter_by('user_id', '==', user_details[0]['user_id']) \
+ .filter_by('auth_type', '!=', 'reference')
+ list_accounts = execute_admin_query(wsgi_request, list_accounts_query)
+
+ # XXX main_platform is being erased several times ???
+ for account in list_accounts:
+ main_platform_query = Query().get('local:platform') \
+ .select('platform_id', 'platform') \
+ .filter_by('platform_id', '==', account['platform_id'])
+ main_platform = execute_admin_query(wsgi_request, main_platform_query)
+
+ # Add reference accounts on SFA enabled platforms
+ platforms_query = Query().get('local:platform') \
+ .filter_by('disabled', '==', '0') \
+ .filter_by('gateway_type', '==', 'sfa') \
+ .select('platform_id', 'gateway_type')
+ platforms = execute_admin_query(wsgi_request, platforms_query)
+ for platform in platforms:
+ #print "add reference to platform ",platform
+ manifold_account_params = {
+ 'user_id' : user_details[0]['user_id'],
+ 'platform_id' : platform['platform_id'],
+ 'auth_type' : 'reference',
+ 'config' : '{"reference_platform": "' + main_platform[0]['platform'] + '"}',
+ }
+ manifold_add_account(wsgi_request, manifold_account_params)
+
+def sfa_create_user(wsgi_request, request):
+ """
+ Arguments:
+ wsgi_request (~ WSGIRequest) :
+ request (dict) : the user request in our own dict format
+
+ Raises:
+ Exception
+ """
+ from sfa.util.xrn import Xrn
+
+ auth_pi = request.get('pi', None)
+ auth_pi = list([auth_pi]) if auth_pi else list()
+
+ # We create a user request with Manifold terminology
+ sfa_user_params = {
+ 'user_hrn' : request['user_hrn'],
+ 'user_email' : request['email'],
+ 'user_urn' : Xrn(request['user_hrn'], request['type']).get_urn(),
+ 'user_type' : request['type'],
+ 'keys' : request['public_key'],
+ 'user_first_name' : request['first_name'],
+ 'user_last_name' : request['last_name'],
+ 'pi_authorities' : auth_pi,
+ 'user_enabled' : True
+ }
+
+ query = Query.create('user').set(sfa_user_params).select('user_hrn')
+ results = execute_query(wsgi_request, query)
+ if not results:
+ raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn']
+ return results
+
+#def ldap_create_user
+
+def create_user(wsgi_request, request):
+
+ # XXX This has to be stored centrally
+ USER_STATUS_ENABLED = 2
+
+ # NOTE : if we were to create a user directly (just like we create slices,
+ # we would have to perform the steps in create_pending_user too
+
+ # Add the user to the SFA registry
+ sfa_create_user(wsgi_request, request)
+
+ # Update Manifold user status
+ manifold_update_user(wsgi_request, request['email'], {'status': USER_STATUS_ENABLED})
+
+ # Add reference accounts for platforms
+ manifold_add_reference_user_accounts(wsgi_request, request)
+
+def create_pending_user(wsgi_request, request, user_detail):
+ """
+ """
+
+ # Insert an entry in the PendingUser table
+ b = PendingUser(
+ first_name = request['first_name'],
+ last_name = request['last_name'],
+ authority_hrn = request['authority_hrn'],
+ email = request['email'],
+ password = request['password'],
+ public_key = request['public_key'],
+ private_key = request['private_key'],
+ user_hrn = request['user_hrn'],
+ pi = '', # XXX Why not None ?
+ )
+ b.save()
+
+ # saves the user to django auth_user table [needed for password reset]
+ user = User.objects.create_user(request['email'], request['email'], request['password'])
+
+ # Creating a manifold user
+ user_id = manifold_add_user(wsgi_request, request)
+
+ # Creating a Manifold account on the MySlice platform
+ # Note the JSON representation of public and private keys already includes quotes
+ account_config = {
+ 'user_hrn' : request['user_hrn'],
+ 'user_public_key' : request['public_key'],
+ }
+ if request['private_key']:
+ account_config['user_private_key'] = request['private_key']
+
+ user_id = user_detail['user_id'] + 1 # the user_id for the newly created user in local:user
+
+ # XXX TODO: Require a myslice platform
+ # ALERT: this will disapear with ROUTERV2 of Manifold
+ # We have to consider the case where several registries can be used
+ # Removed hardcoded platform = 5
+ # This platform == 'myslice' is a TMP FIX !!
+ try:
+ reg_platform_query = Query().get('local:platform') \
+ .filter_by('platform', '==', 'myslice') \
+ .select('platform_id')
+ reg_platform = execute_admin_query(wsgi_request, reg_platform_query)
+
+ registry_platform_id = reg_platform[0]['platform_id']
+ account_params = {
+ 'platform_id' : reg_platform_id, # XXX ALERT !!
+ 'user_id' : user_id,
+ 'auth_type' : request['auth_type'],
+ 'config' : json.dumps(account_config),
+ }
+ manifold_add_account(wsgi_request, account_params)
+ except Exception, e:
+ print "Failed creating manifold account on platform %s for user: %s" % ('myslice', request['email'])
+
+ try:
+ # Send an email: the recipients are the PI of the authority
+ # If No PI is defined for this Authority, send to a default email (different for each theme)
+ recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
+
+ theme.template_name = 'user_request_email.html'
+ html_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'user_request_email.txt'
+ text_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'user_request_email_subject.txt'
+ subject = render_to_string(theme.template, request)
+ subject = subject.replace('\n', '')
+
+ theme.template_name = 'email_default_sender.txt'
+ sender = render_to_string(theme.template, request)
+ sender = sender.replace('\n', '')
+
+ msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+ msg.attach_alternative(html_content, "text/html")
+ msg.send()
+ except Exception, e:
+ print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn']
return results
+def ldap_create_user(wsgi_request, request, user_detail):
+ """
+ Populating LDAP withuser data - Edelberto 10/03/2014
+ """
+ # import needed modules
+ import ldap
+ import ldap.modlist as modlist
+
+ # Open a connection
+ # XXX We need to create this in settings
+ # ldap.open is deprecated!
+ #l = ldap.open("127.0.0.1")
+ l = ldap.initialize('ldap://127.0.0.1:389')
+
+ # you should set this to ldap.VERSION2 if you're using a v2 directory
+ l.protocol_version = ldap.VERSION3
+
+ # Bind/authenticate with a user with apropriate rights to add objects
+ # XXX Now we set the force rootd but after we need to set this in settings file for could change the dn and password of root
+ l.simple_bind_s("cn=Manager,dc=br","fibre")
+
+ # The dn of our new entry/object
+ #dn="uid=addtest@uff.br,ou=people,o=uff,dc=br"
+
+ # we need to create the dn entry
+ # Receiving an email address, how can we split and mount it in DN format?
+ #mail = "debora@uff.br"
+ mail = request['email']
+ login = mail.split('@')[0]
+ org = mail.split('@')[1]
+ o = org.split('.')[-2]
+ dc = org.split('.')[-1]
+
+ # DN format to authenticate - IMPORTANT!
+ #FIBRE-BR format
+ dn = "uid="+mail+",ou=people,o="+o+",dc="+dc
+
+ # DEBUG
+ print "dn:"+dn
+ print request['password']
+
+ # Creating a unique uidNumber - Necessary for experiments
+ # Was defined to began in 100000
+ unique = int(user_detail['user_id']) + 100000
+ #unique = int(unique)
+ print unique
+
+ # A dict to help build the "body" of the object
+ attrs = {}
+ attrs['objectclass'] = ['person','inetOrgPerson','posixAccount','eduPerson','brPerson','schacPersonalCharacteristics','fibre', 'ldapPublicKey']
+ # XXX Converting all unicodes to string
+ attrs['uid'] = mail.encode('utf-8')
+ attrs['cn'] = request['first_name'].encode('latin1')
+ attrs['sn'] = request['last_name'].encode('latin1')
+ # XXX we need to set a unique uidNumber. How?
+ attrs['uidNumber'] = str(unique)
+ attrs['gidNumber'] = '500'
+ attrs['homeDirectory'] = "/home/"+org+"/"+mail
+ attrs['homeDirectory'] = attrs['homeDirectory'].encode('utf-8')
+ attrs['mail'] = mail.encode('utf-8')
+ attrs['eppn'] = mail.encode('utf8')
+ attrs['userPassword'] = request['password'].encode('utf-8')
+ attrs['sshPublicKey'] = request['public_key'].encode('utf-8')
+ # XXX We really set TRUE for those attributes?
+ #attrs['userEnable'] = 'TRUE'
+ # set FALSE and change after when the user is validated
+ attrs['userEnable'] = 'FALSE'
+ attrs['omfAdmin'] = 'TRUE'
+
+ # Convert our dict to nice syntax for the add-function using modlist-module
+ ldif = modlist.addModlist(attrs)
+
+ # DEBUG
+ print attrs['userPassword']
+ print attrs['cn']
+ print attrs['sn']
+ print attrs['homeDirectory']
+ #print ldif
+
+ # Do the actual synchronous add-operation to the ldapserver
+ l.add_s(dn,ldif)
+
+ # Its nice to the server to disconnect and free resources when done
+ l.unbind_s()
+
+ return ldif
+
+def ldap_modify_user(wsgi_request, request):
+ #Modify entries in an LDAP Directory
+
+ #Synchrounous modify
+ # import needed modules
+ import ldap
+ import ldap.modlist as modlist
+
+ # Open a connection
+ l = ldap.initialize("ldap://localhost:389/")
+
+ # Bind/authenticate with a user with apropriate rights to add objects
+ l.simple_bind_s("cn=Manager,dc=br","fibre")
+
+ # we need to create the dn entry
+ # Receiving an email address, how can we split and mount it in DN format?
+ #mail = "debora@uff.br"
+ mail = request['email']
+ login = mail.split('@')[0]
+ org = mail.split('@')[1]
+ o = org.split('.')[-2]
+ dc = org.split('.')[-1]
+
+ # DN format to authenticate - IMPORTANT!
+ #FIBRE-BR format
+ dn = "uid="+mail+",ou=people,o="+o+",dc="+dc
+
+ # The dn of our existing entry/object
+ #dn="uid=mario@uff.br,ou=people,o=uff,dc=br"
+
+ # Some place-holders for old and new values
+ old = {'userEnable':'FALSE'}
+ new = {'userEnable':'TRUE'}
+
+ # Convert place-holders for modify-operation using modlist-module
+ ldif = modlist.modifyModlist(old,new)
+
+ # Do the actual modification
+ l.modify_s(dn,ldif)
+
+ # Its nice to the server to disconnect and free resources when done
+ l.unbind_s()
+
+ return ldif
+
def create_user(wsgi_request, request):
# XXX This has to be stored centrally
# NOTE : if we were to create a user directly (just like we create slices,
# we would have to perform the steps in create_pending_user too
+
# Add the user to the SFA registry
sfa_create_user(wsgi_request, request)
# Add reference accounts for platforms
manifold_add_reference_user_accounts(wsgi_request, request)
+ # LDAP update user userEnabled = True
+ mail = request['email']
+ login = mail.split('@')[0]
+ org = mail.split('@')[1]
+ o = org.split('.')[-2]
+ dc = org.split('.')[-1]
+ # To know if user is a LDAP user - Need to has a 'dc' identifier
+ if dc == 'br' or 'eu':
+ ldap_modify_user(wsgi_request, request)
+
def create_pending_user(wsgi_request, request, user_detail):
"""
"""
.filter_by('platform', '==', 'myslice') \
.select('platform_id')
reg_platform = execute_admin_query(wsgi_request, reg_platform_query)
-
reg_platform_id = reg_platform[0]['platform_id']
account_params = {
'platform_id' : reg_platform_id, # XXX ALERT !!
}
manifold_add_account(wsgi_request, account_params)
except Exception, e:
- print "Failed creating manifold account on platform %s for user: %s" % ('myslice', request['email'])
+ print "Failed creating manifold account on platform %s for user: %s" % ('myslice', request['email'])
+
+ # Add user to LDAP userEnabled = False
+ # Not more here. Create before directly to the registrationview.py
+ # After we change userEnable = TRUE when validate the user
try:
# Send an email: the recipients are the PI of the authority
env['theme'] = self.theme
username = request.POST.get('username')
password = request.POST.get('password')
+
+ # LDAP form - If FIBRE, then get the possibilite to authenticate using usernameldap
+ #if self.theme == 'fibre':
+ usernameldap = request.POST.get('usernameldap')
+ token = {'usernameldap': usernameldap, 'username': username ,'password': password, 'request': request}
+ #else:
- # pass request within the token, so manifold session key can be attached to the request session.
- token = {'username': username, 'password': password, 'request': request}
+ # Follow original code
+ ## pass request within the token, so manifold session key can be attached to the request session.
+ #token = {'username': username, 'password': password, 'request': request}
# our authenticate function returns either
# . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
from manifold.core.query import Query
from portal.models import PendingUser
-from portal.actions import create_pending_user
+#from portal.actions import create_pending_user
+# Edelberto - LDAP
+from portal.actions import create_pending_user, ldap_create_user
from theme import ThemeView
user_request['public_key'] = file_content
if not errors:
+ # verify if is a LDAP
+ mail = user_detail['email']
+ login = mail.split('@')[0]
+ org = mail.split('@')[1]
+ o = org.split('.')[-2]
+ dc = org.split('.')[-1]
+ # To know if user is a LDAP user - Need to has a 'dc' identifier
+ if dc == 'br' or 'eu':
+ # LDAP insert directly - but with userEnable = FALSE
+ ldap_create_user(wsgi_request, user_request, user_detail)
+
create_pending_user(wsgi_request, user_request, user_detail)
self.template_name = 'user_register_complete.html'
+
return render(wsgi_request, self.template, {'theme': self.theme})
else:
--- /dev/null
+body {
+ background-color:white;
+ color:black;
+ margin:0;
+ padding:0;
+}
+a, a:active, a:focus {
+ outline: 0;
+}
+
+h1 {
+ border-bottom:1px solid #DDDDDD;
+ padding:0 0 5px 0;
+ margin:0 0 15px 0;
+ font-size:18pt;
+}
+h1 img {
+ vertical-align:middle;
+ margin-bottom:4px;
+}
+h2 {
+ font-size:14pt;
+ color:#333333;
+}
+h3 {
+ font-size:13pt;
+ color:#201E62;
+}
+div.wrapper {
+ width:980px;
+ margin:0 auto;
+ position:relative;
+}
+div.container {
+ width:80%;
+ margin:25px auto;
+}
+div.wide {
+ margin:25px auto;
+ padding:0 25px;
+}
+
+span.label {
+ font-size:11pt;
+ color:gray;
+ font-weight:normal;
+ padding:0;
+}
+/***** Notifications *****/
+.warning {
+ border: 1px solid red;
+ margin: 20px 60px;
+ padding: 10px 20px;
+ color: red;
+ background-color: #f2dbdb;
+ text-align: center;
+}
+/* HEADER */
+div#header {
+ height:100px;
+ background-color:white;
+}
+
+div#secondary {
+
+}
+
+div#secondary ul {
+ position:absolute;
+ top:20px;
+ right:0;
+}
+
+div#secondary li {
+ font-size:10pt;
+ float:left;
+ list-style:none;
+ margin-right:30px;
+}
+div#secondary li a {
+ color:black;
+}
+div#secondary li a:hover {
+ color:#270A5A;
+ text-decoration:none;
+}
+div#secondary li:last-child {
+ margin-right:0;
+}
+
+div#navigation {
+ background-color:rgb(30, 88, 111);
+ width:100%;
+ height:40px;
+}
+div#navigation div.wrapper {
+ text-align:center;
+}
+div#navigation ul {
+ margin:0;
+ padding:0;
+ display: inline-block;
+ list-style-type: none;
+ white-space: nowrap;
+}
+
+div#navigation li {
+ color:white;
+ font-family:helvetica, sans-serif;
+ font-size:10pt ;
+ font-weight:normal;
+ line-height:0.8em;
+ letter-spacing:0.6pt;
+ list-style:none;
+ float:left;
+ padding:0;
+ margin:15px 50px 0 0;
+}
+div#navigation li a {
+ color:white;
+}
+div#navigation li a:hover {
+ text-decoration:none;
+ color:#B8B2FF;
+}
+div#navigation li:last-child {
+ margin-right:0;
+}
+
+/* HOME DASHBOARD */
+div#home-dashboard {
+ color:black;
+ margin:0 auto 25px auto;
+}
+div#home-dashboard table {
+/* margin:25px; */
+ width:100% !important;
+}
+div#home-dashboard table td {
+ text-align:center;
+ padding:15px 0;
+ width:33%;
+}
+div#home-dashboard table tr:first-child td {
+ font-size:12pt;
+ font-weight:bold;
+ color:#270A5A;
+}
+div#home-dashboard table tr:last-child td {
+ vertical-align:top;
+ padding:25px 0;
+}
+div#home-dashboard table tr:last-child td.logged-in {
+ /* border-right:1px solid #DDDDDD; */
+ padding:25px;
+}
+div#home-dashboard table tr:last-child td.support {
+ /* border-left:1px solid #DDDDDD; */
+ padding:25px;
+}
+div#home-dashboard table tr:last-child td:first-child {
+}
+div#home-dashboard table tr:last-child td:last-child {
+ border-right:0;
+}
+div#home-dashboard table tr:last-child td.logged-in div {
+ text-align:left;
+ padding:25px 0;
+}
+div#home-dashboard table tr:last-child td.support div {
+ text-align:left;
+ padding:25px 0;
+}
+
+/* Edelberto */
+.bar1 {
+ width: 100%;
+ background: #FCFCFC;
+ border: 1px;
+ border-radius: 4px;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+}
+
+.well {
+ width: 350px !important;
+}
+
+#footer {
+ width: 100%;
+ float: left;
+ background-color: rgb(65, 119, 139);
+ height: 30px;
+ padding: 5px;
+ text-align: center;
+ color: white;
+}
+
+.logo {
+ padding-bottom: 5px;
+}
+
+/* Edelberto end */
+
+div#home-dashboard div.login-widget {
+ padding:20px;
+}
+div#home-dashboard table td.support {
+}
+div#home-dashboard table td.support a {
+}
+div#home-dashboard table td.support a:hover {
+ text-decoration:none;
+}
+
+div#home-dashboard div#manager {
+ display:none;
+}
+
+div#home-dashboard div#home-slice-list {
+ margin:25px 0;
+ padding:0 25px;
+ text-align:left;
+}
+div#home-dashboard div#home-slice-list ul {
+ list-style: none;
+ padding:0;
+ margin:0;
+}
+div#home-dashboard div#home-slice-list li {
+
+}
+
+.login-submit {
+ vertical-align:middle;
+ padding:0;
+}
+.lost-password {
+ font-size:10pt;
+ color:#CCCCCC;
+ text-align:right;
+ padding:0px;
+}
+.lost-password a {
+}
+.login-signup {
+ border-top:1px solid #CCCCCC;
+ text-align:center;
+ margin-top:15px;
+ padding:5px 0 0 0;
+}
+/**/
+
+/* NAV TABS */
+
+.nav.nav-tabs {
+ margin-bottom:25px;
+}
+
+.nav.nav-tabs li.active a {
+
+}
+
+.nav.nav-tabs li a {
+}
+
+.nav.nav-tabs li a:hover {
+}
+
+/**/
+/* WELL */
+div.well {
+}
+/**/
+/* BUTTON */
+.btn.btn-default {
+ font-weight: bold;
+}
+
+.btn.btn-default:hover {
+ font-weight: bold;
+}
+/**/
+/* TABLE */
+table.table {
+ margin:0;
+}
+table.table thead {
+ padding:0;
+}
+table.table tbody {
+ padding:0;
+}
+table.table tr {
+ padding:0;
+}
+table.table td {
+ padding:0;
+}
+/* INSTITUTION */
+div#institution {
+ color:black;
+}
+.form-hint {
+ font-size:11pt;
+ font-style:italic;
+ color:gray;
+}
+
+
+.form-hint {
+ font-size:11pt;
+ font-style:italic;
+ color:gray;
+}
+
+
+
+/* TICKET REQUEST */
+div#ticket-request {
+ color:black;
+}
+.form-hint {
+ font-size:11pt;
+ font-style:italic;
+ color:gray;
+}
+div#ticket-request p {
+ margin:20px 0;
+}
+
+/* SLICE VIEW */
+div#slice-view {
+ margin:0;
+}
+div.list-group-item {
+ border:0;
+ background-color:white;
+ font-weight:bold;
+ padding-left:0;
+}
+a.list-group-item {
+ border:0;
+ background-color:white;
+ padding:3px 0 3px 10px;
+ border-left:2pt white solid;
+}
+a.list-group-item.active, a.list-group-item:hover {
+ border-left:2pt blue solid;
+}
+a.list-group-item p.list-group-item-text {
+ font-size:9pt;
+ font-style:italic;
+}
+
+/* SLICE VIEW sections */
+.slice-sections, .slice-pending {
+ margin:0;
+ padding:0;
+}
+.slice-sections ul, .slice-pending ul {
+ margin:0;
+ padding:0;
+}
+.slice-pending ul {
+ width:400px;
+ margin:0 auto 15px auto;
+}
+.slice-sections li {
+ text-align:left;
+ margin:0;
+ padding:0;
+}
+.slice-pending li {
+ padding-right:15px;
+}
+.slice-sections li a, .slice-pending li a {
+ font-size:14px;
+ color:black;
+ padding:0;
+}
+.slice-sections li.active a, .slice-pending li.active a {
+ color:#201E62;
+ background-color:#EFEFEF;
+ text-decoration:underline;
+ padding:0;
+}
+.slice-sections ul.nav-pills li a:hover, .slice-pending ul.nav-pills li a:hover {
+ text-decoration:underline;
+ background-color:#EFEFEF;
+ color:black;
+}
+.slice-sections ul.nav-pills li.active, .slice-pending ul.nav-pills li.active {
+
+}
+.slice-sections li:first-child, .slice-sections li:first-child a {
+ color:#201E62;
+ font-weight:bold;
+}
+.slice-experiment {
+ text-align:right;
+ padding:0;
+}
+.slice-experiment button {
+ margin:3px 0 0 0;
+ background-color:#CC4125;
+ color:white;
+}
+
+.slice-pending {
+}
+.slice-pending button {
+ font-size:9pt;
+ margin:-2px 0 0 0;
+ padding:3px 5px;
+}
+.slice-pending button.apply {
+}
+.slice-pending button.clear {
+}
--- /dev/null
+/* @override unfold/static/css/plugin.css */
+
+/*-------------------------------- MARKO'S STYLES -----*/
+
+/* GENERAL */
+
+a, a:visited {
+ color: rgb(13, 187, 255) !important;
+ text-decoration: none !important;
+}
+
+a:hover {
+ color: blue !important;
+ text-decoration: none !important;
+}
+
+.container {
+ /*padding: 0 !important;*/
+ padding-top: 60px !important;
+ color: #fff;
+/* background: url(http://new.fit-equipex.fr/images/background.jpg) no-repeat; */
+ background-color: rgb(237, 241, 243);
+ margin: 0;
+ width: 100%;
+ max-width: 100%;
+ min-height: 100%;
+ height: 100%;
+}
+
+.container h1, .container h2 {
+ color: #fff !important;
+}
+
+.navbar-brand {
+ padding: 5px !important;
+}
+
+.nav {
+ padding-top: 30px !important;
+ padding-left: 20px !important;
+}
+
+.navbar-default {
+ background-color: #fff !important;
+}
+
+p.login-status {
+ color: blue !important;
+}
+
+div.plugin-outline-complete,
+div.plugin-outline-body {
+ border: 0px solid;
+ border-radius: 0;
+ border-color: #ccc;
+ -webkit-transition: padding 200ms ease-out;
+ -moz-transition: padding 200ms ease-out;
+ -o-transition: padding 200ms ease-out;
+ transition: padding 0.2s ease-out;
+ padding: 20px;
+ margin: 0;
+}
+/*
+div.plugin-outline-complete:hover,
+div.plugin-outline-body:hover {
+ padding: 80px 80px 120px 80px;
+}
+*/
+a.plugin-tooltip {
+ font-size: 130%;
+ font-style: normal;
+ font-weight: bold;
+ padding: 5px;
+ color: #333;
+ font-family: Ubuntu, Arial, sans-serif;
+ text-transform: uppercase;
+}
+
+a.plugin-tooltip:hover {
+ color: #fff;
+ text-decoration: none;
+}
+
+
+
+/* LIST VIEW */
+div.well-lg {
+ background-color: rgba(168, 32, 202, 0.5) !important;
+}
+div.onelab-title {
+ background-color: #3A5FCD !important;
+ /*background-color: rgba(168, 32, 202, 0.5) !important;*/
+}
+div.well {
+ /*background-color: rgba(0, 0, 0, 0.5) !important;*/
+ background-color: #fff !important;
+ color: rgb(37, 37, 37) !important;
+}
+h2.well.well-lg {
+ border-radius:0;
+ border: 0;
+ font-family: Ubuntu, arial, sans-serif;
+ /* text-transform: ; */
+ font-weight: normal;
+ font-size: 40px;
+ /* color: #30196d; */
+ color: white;
+ margin-bottom: 0px;
+ margin-top: 0;
+ padding: 40px;
+ opacity: 1;
+ text-align: center;
+ background-color: #30196d;
+}
+
+#complete-resources {
+/* background-color: #92f79e !important; */
+ background-color: #B8B2FF !important;
+}
+
+#complete-filters {
+/* background-color: #4af25d; */
+ background-color: #add7ff;
+}
+
+#complete-users {
+/* background-color: #ff7394 !important; */
+ background-color: #add7ff !important;
+}
+/*
+#complete-measurements {
+ background-color: !important;
+}
+*/
+#complete-pending {
+/* background-color: #add7ff !important; */
+ background-color: #B8B2FF !important;
+
+}
+
+#complete-customize-resources {
+ background-color: #efdfdf;
+}
+
+#complete-msgs-pre {
+ background-color: #ccc;
+}
+
+#complete-resources,
+#complete-filters,
+#complete-users,
+#complete-measurements,
+#complete-pending,
+#complete-customize-resources,
+#complete-msgs-pre {
+ opacity: 1;
+ text-align: center;
+ color: #333;
+}
+
+#complete-resources:hover,
+#complete-filters:hover,
+#complete-users:hover,
+#complete-measurements:hover,
+#complete-pending:hover,
+#complete-customize-resources:hover,
+#complete-msgs-pre:hover {
+ opacity: 1;
+}
+
+.nav.nav-tabs {
+ font-family: Ubuntu, Arial, sans-serif;
+ border: 0 !important;
+ border-bottom: 3px solid #fff !important;
+ margin-bottom: 40px;
+}
+
+.nav.nav-tabs li.active a {
+ color: #572bc9;
+ border-left: 0px solid #572bc9;
+ border-top: 0px solid #572bc9;
+ border-right: 0px solid #572bc9;
+}
+
+.nav.nav-tabs li a {
+ color: #333;
+ border: 0 !important;
+ margin-right: 5px;
+}
+
+.nav.nav-tabs li a:hover {
+ color: #333;
+ background: #572bc9;
+ color: #fff;
+ border: 0 !important;
+}
+
+
+
+/* if window enlarged wider than background picture */
+body {
+ background: rgb(237, 241, 243) !important;
+ /*background: black !important;*/
+}
+
+/* TOPMENU.CSS */
+
+/* Thierry : turning this off
+body {
+ *//* background: #30196d !important; *//*
+ background: black !important;
+ padding-top: 60px;
+ padding-bottom: 0px;
+}
+Thierry */
+
+/* Thierry : turning this off
+div.topmenu {
+ padding-top: 0px;
+ font-family: Ubuntu, Arial, sans-serif;
+ font-weight: bold;
+ background: #fff;
+ -webkit-box-shadow: 0px 10px 10px rgba(50, 50, 50, 0.44);
+ -moz-box-shadow: 0px 10px 10px rgba(50, 50, 50, 0.44);
+ box-shadow: 0px 10px 10px rgba(50, 50, 50, 0.44);
+}
+Thierry */
+
+/* Thierry : turning this off
+.navbar-nav li a,
+.navbar-nav li.other a {
+ padding-top: 25px;
+ padding-bottom: 20px;
+}
+Thierry */
+
+.navbar-nav li a:hover {
+ color: #572bc9 !important;
+}
+
+.navbar-nav li.active a {
+ background: #eee !important;
+}
+
+/* Thierry : turning this off
+ul.logged-in {
+ padding-top: 25px;
+}
+Thierry */
+button.logged-in {
+ font-size: 1em;
+ font-weight: bold;
+ margin-left: 5px;
+ margin-top: -5px;
+ background: #572bc9;
+ border: 2px solid #572bc9;
+ color: #eee;
+ padding: 5px 15px;
+ border-radius:5px;
+}
+
+button.logged-in:hover {
+ /* background: #4af25d; */
+ background: #ff7394;
+ border: 2px solid #ff7394;
+ color: #333;
+}
+li.username {
+ margin-bottom: 10px;
+ font-size: 0.8em;
+ text-transform: none;
+ font-weight: normal;
+ color: #999;
+}
+
+
+/* BOOTSTRAP */
+
+
+ul.pagination li a {
+ /* background: ; */
+ color: #572bc9;
+ font-family: Ubuntu, Arial, sans-serif;
+}
+
+ul.pagination li.active a {
+ background: #572bc9;
+ border: 1px solid #572bc9;
+}
+
+.btn.btn-default {
+ background: #572bc9;
+ color: #ccc;
+ font-family: Ubuntu, Arial, sans-serif;
+ font-weight: bold;
+ border: 0px;
+}
+
+.btn.btn-default:hover {
+ /* background: #4af25d; */
+ background: #ff7394;
+ color: #333;
+ font-family: Ubuntu, Arial, sans-serif;
+ font-weight: bold;
+ border: 0px;
+}
+
+input {
+ border-radius: 3px;
+ border: none;
+ border: 1px solid #ccc;
+}
+
+
+div.dataTables_length label,
+div.dataTables_filter label,
+div.dataTables_info {
+ font-family: Ubuntu, Arial, sans-serif !important;
+}
+
+
+
+
+/* QUERYTABLE */
+
+div.QueryTable table.dataTable th {
+ font: bold 12px/22px Ubuntu, Arial, sans-serif;
+ color: #333 !important;
+ border-right: 0px solid #333 !important;
+ border-bottom: 0px solid #C1DAD7 !important;
+ border-top: 0px solid #C1DAD7 !important;
+ letter-spacing: 1px;
+ text-transform: uppercase;
+ text-align: left;
+ padding: 8px 12px 4px 20px;
+ vertical-align:middle;
+ background: url('../img/tablesort-header.png') no-repeat !important;
+}
+
+div.QueryTable table.dataTable td, div.QueryTable table.dataTable textarea, div.QueryTable table.dataTable input [type="text"] {
+ font: normal 12px Ubuntu, Arial, Helvetica, sans-serif;
+ border-right: 0px solid #fff !important;
+ border-bottom: 1px solid #fff !important;
+}
+
+div.QueryTable table.dataTable thead {
+ background: url('../img/tablesort-header.png') repeat-x !important;
+ background-color: #caebea;
+}
+
+div.QueryTable table.dataTable tfoot {
+ background: url('../img/tablesort-header.png') repeat-x !important;
+ /* background-color: # !important; */
+}
+
+
+/* QUERY EDITOR */
+
+table.query-editor {
+ margin: 40px auto !important;
+ clear: both;
+ /* width: 80%;*/
+ width: 100% !important;
+ font-family: Ubuntu;
+}
+
+.query-editor-spacer,
+.plugin.QueryUpdater,
+/* Thierry : turning this off
+.plugin.Tabs
+Thierry */
+{
+ margin-top: 60px !important;
+}
+
+table.query-editor td {
+ padding: 5px 5px !important;
+ font: normal 12px Ubuntu, Arial, sans-serif !important;
+}
+
+
+
+/* DASHBOARD */
+
+#ms-dashboard-profile,
+#ms-dashboard-testbeds,
+#ms-dashboard-slices {
+ -webkit-transition: all 50ms ease-out;
+ -moz-transition: all 50ms ease-out;
+ -o-transition: all 50ms ease-out;
+ transition: all 0.05s ease-out;
+ padding-top: 140px;
+ padding-bottom: 60px;
+ margin-top: 60px;
+ color: #fff;
+ font-family: Ubuntu, Arial, sans-serif;
+ text-align: center;
+
+}
+
+#ms-dashboard-profile:hover,
+#ms-dashboard-testbeds:hover,
+#ms-dashboard-slices:hover {
+ margin-top: 65px;
+}
+
+#ms-dashboard-profile {
+ background: url("../img/icon_users_color.png") top center no-repeat;
+}
+
+#ms-dashboard-testbeds {
+ background: url("../img/icon_testbed_color.png") top center no-repeat;
+}
+
+#ms-dashboard-slices {
+ background: url("../img/icon_slices_color.png") top center no-repeat;
+}
+
+.ms-dashboard-content ul {
+ list-style-type: none !important;
+ padding-left: 0;
+ text-align: center !important;
+}
+
+.ms-dashboard-content {
+ padding: 0 !important;
+}
+
+.ms-dashboard-content a {
+ color: #ff7394 !important;
+/* color: #ff0099 !important; */
+}
+
+.ms-dashboard-content a:hover {
+ color: white !important;
+}
+.ms-dashboard-caption h2 {
+ font-family: Ubuntu, Arial, sans-serif;
+ border-bottom: 0 !important;
+ text-transform: uppercase;
+}
+
+#ms-dashboard-profile>div.ms-dashboard-caption {
+ background: no-repeat url(#) !important;
+ padding-left: 0 !important;
+}
+
+#ms-dashboard-testbeds>div.ms-dashboard-caption {
+ background: no-repeat url(#) !important;
+ padding-left: 0 !important;
+}
+
+#ms-dashboard-slices>div.ms-dashboard-caption {
+ background: no-repeat url(#) !important;
+ padding-left: 0 !important;
+}
+
--- /dev/null
+<div class="well">
+ {% if state %}
+ <span class="help-block">{{ state }}</span>
+ {% endif %}
+ <form action="/login/" method="post" role="form">
+ {% csrf_token %}
+ {% if next %}
+ <input type="hidden" name="next" value="{{ next }}" />
+ {% endif %}
+ <div class="form-group">
+ <label for="username">Email address / Username</label>
+ <input type="email" class="form-control" name="username" placeholder="Enter Email / username">
+ </div>
+ <div class="form-group">
+ <label for="password">Password</label>
+ <input type="password" class="form-control" name="password" placeholder="Password">
+ </div>
+ <div class="login-submit">
+ <input class="btn btn-default" type="submit" value="Sign In" />
+ <span class="lost-password"> | <a href="/portal/pass_reset/">Can't access your account?</a></span>
+ </div>
+ <div class="login-signup">
+ <a href="/portal/register">Try</a>, <a href="/portal/register">Sign Up</a> or <a href="/portal/join">Join</a>
+ </div>
+ </form>
+</div>
--- /dev/null
+<div class="well login-widget">
+ {% if state %}
+ <span class="help-block">{{ state }}</span>
+ {% endif %}
+ <form action="/login/" method="post" role="form">
+ {% csrf_token %}
+ {% if next %}
+ <input type="hidden" name="next" value="{{ next }}" />
+ {% endif %}
+ <div class="form-group">
+ <label for="usernameldap">LDAP User</label>
+ <input type="email" class="form-control" name="usernameldap" placeholder="LDAP user">
+ </div>
+ <div class="form-group">
+ <label for="password">Password</label>
+ <input type="password" class="form-control" name="password" placeholder="Password">
+ </div>
+ <div class="login-submit">
+ <input class="btn btn-default" type="submit" value="Sign In" />
+ <span class="lost-password"> | <a href="/portal/pass_reset/">Can't access your account?</a></span>
+ </div>
+ <div class="login-signup">
+ <a href="/portal/register">Try</a> or <a href="/portal/register">Sign Up</a>
+ </div>
+ </form>
+</div>
--- /dev/null
+<div class="well">
+ {% if state %}
+ <span class="help-block">{{ state }}</span>
+ {% endif %}
+ <form action="/login/" method="post" role="form">
+ {% csrf_token %}
+ {% if next %}
+ <input type="hidden" name="next" value="{{ next }}" />
+ {% endif %}
+ <div class="form-group">
+ <label for="username">Email address / Username</label>
+ <input type="email" class="form-control" name="username" placeholder="Enter Email / username">
+ </div>
+ <div class="form-group">
+ <label for="password">Password</label>
+ <input type="password" class="form-control" name="password" placeholder="Password">
+ </div>
+ <div class="login-submit">
+ <input class="btn btn-default" type="submit" value="Sign In" />
+ <span class="lost-password"> | <a href="/portal/pass_reset/">Can't access your account?</a></span>
+ </div>
+ <div class="login-signup">
+ <a href="/portal/register">Try</a>, <a href="/portal/register">Sign Up</a> or <a href="/portal/join">Join</a>
+ </div>
+ </form>
+</div>
--- /dev/null
+<div class="well login-widget">
+ {% if state %}
+ <span class="help-block">{{ state }}</span>
+ {% endif %}
+ <form action="/login/" method="post" role="form">
+ {% csrf_token %}
+ {% if next %}
+ <input type="hidden" name="next" value="{{ next }}" />
+ {% endif %}
+ <div class="form-group">
+ <label for="username">Email address / Username</label>
+ <input type="email" class="form-control" name="username" placeholder="Enter Email / username">
+ </div>
+ <div class="form-group">
+ <label for="password">Password</label>
+ <input type="password" class="form-control" name="password" placeholder="Password">
+ </div>
+ <div class="login-submit">
+ <input class="btn btn-default" type="submit" value="Sign In" />
+ <span class="lost-password"> | <a href="/portal/pass_reset/">Can't access your account?</a></span>
+ </div>
+ <div class="login-signup">
+ <a href="/portal/register">Try</a> or <a href="/portal/register">Sign Up</a>
+ </div>
+ </form>
+</div>
--- /dev/null
+{% insert_str prelude "js/bootstrap.js" %}
+{% insert_str prelude "css/bootstrap.css" %}
+{% insert_str prelude "css/topmenu.css" %}
+{% insert_str prelude "js/logout.js" %}
+<div id="header">
+ <div class="wrapper">
+ <div class="logo">
+ <a href="/"><img width="145px" height="75px" src="{{ STATIC_URL }}img/fibre-logo.gif" alt=FIBRE" /></a>
+ </div>
+
+ <div id="secondary">
+ <ul>
+ <li>News</li>
+ <li><a href="/portal/about">About</a></li>
+ <li><a target="_blank" href="http://www.fibre-ict.eu">Public Website</a></li>
+ <li><a target="_blank" href="http://intranet.fibre-ict.eu">Intranet</a></li>
+ </ul>
+ </div>
+ </div>
+
+ {% if username %}
+ <div id="navigation">
+ <div class="wrapper">
+ <ul>
+ <li>SLICES</li>
+ <li><a href="/portal/validate">REQUESTS</a></li>
+ <li><a href="/portal/institution">INSTITUTION</a></li>
+ <li><a href="/portal/support/">SUPPORT</a></li>
+ <li>|</li>
+ <li><a href="/portal/account/">{{ username }}</a></li>
+ <li><a id="logout" style="cursor:pointer;" data-username="{{ username }}">LOGOUT</a></li>
+ </ul>
+ </div>
+ </div>
+ {% else %}
+ <div id="navigation">
+ <div class="wrapper"></div>
+ </div>
+ {% endif %}
+</div>
+<script>
+ $(document).ready(function() {
+ // var slices = localStorage.getItem('slices');
+ // if (slices.length == 0) {
+ // $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
+ // var items = [];
+ // localStorage.setItem('slices', data[0].slice);
+ // });
+ // }
+ // $.each(slices, function( key, val ) {
+ // items.push( "<li><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
+ // });
+ // $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
+ });
+</script>
--- /dev/null
+{# This is required by insert_above #}{% insert_handler %}<!DOCTYPE html>
+<html lang="en"><head>
+<title>FIBRE - {{ section }}</title>
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<link rel="shortcut icon" href="/static/img/myslice-icon.png">
+{# This is where insert_str will end up #}{% media_container prelude %}
+{% include 'messages-transient-header.html' %}
+<script type="text/javascript"> {# raw js code - use {% insert prelude_js %} ... {% endinsert %} #} {% container prelude_js %}</script>
+<script src="{{ STATIC_URL }}js/jquery.dataTables.min.js"></script>
+<script src="{{ STATIC_URL }}js/bootstrap.datatables.js"></script>
+<script src="{{ STATIC_URL }}js/myslice-ui.js"></script>
+<style type="text/css">{# In case we need to add raw css code #}{% container prelude_css %}</style>
+{{ header_prelude }}
+{% block head %} {% endblock head %}
+{# let's add these ones no matter what #}
+{% insert_str prelude "js/jquery.min.js" %}
+{% insert_str prelude "js/jquery.html5storage.min.js" %}
+{% insert_str prelude "js/messages-runtime.js" %}
+{% insert_str prelude "js/class.js" %}
+{% insert_str prelude "js/plugin-helper.js" %}
+{% insert_str prelude "js/mustache.js" %}
+{% insert_str prelude "js/plugin.js" %}
+{% insert_str prelude "js/manifold.js" %}
+{% insert_str prelude "css/manifold.css" %}
+{% insert_str prelude "css/plugin.css" %}
+<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/{{ theme }}.css">
+</head>
+<body>
+{% block container %}
+ {% block topmenu %}
+ {% include theme|add:"__widget-topmenu.html" %}
+ {% endblock topmenu %}
+ {% include 'messages-transient.html' %}
+ {% block base_content %}
+ {% endblock %}
+{% endblock container %}
+</body>
+</html>
--- /dev/null
+{% extends "layout.html" %}
+
+{% block content %}
+<div class="row" id="home-dashboard">
+ <ul class="nav nav-tabs">
+ <li class="active"><a class="home-tab" data-panel="user" href="#">USER</a></li>
+ <li><a class="home-tab" data-panel="manager" href="#">MANAGER</a></li>
+ </ul>
+ <div class="home-panel" id="user">
+ <table>
+ <tr>
+ <td>ACCOUNT</td>
+ <td>SLICES</td>
+ <td>SUPPORT</td>
+ </tr>
+ <tr>
+ <td><a href="/portal/account/"><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></a></td>
+ <td><a href="#"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a></td>
+ <td><a href="/portal/support"><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></a></td>
+ </tr>
+ <tr>
+ {% if person %}
+ <td class="logged-in">
+ <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
+ <div>
+ {% if person.last_name %}
+ {{person.first_name}} {{person.last_name}}<br />
+ {% endif %}
+ <span class="label">Email:</span> <a href='/portal/account/'>{{person.email}}</a>
+ </div>
+ {% else %}
+ <td>
+ {% include 'fibre__widget-login-user.html' %}
+ {% include 'fibre__widget-login-ldap-user.html' %}
+ {% endif %}
+ </td>
+ <td>
+ {% if person %}
+ <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request a Slice</button>
+ <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+ {% else %}
+ {% endif %}
+ </td>
+ <td class="support">
+ <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Ticket</button>
+ <div>
+ <a href="/portal/contact">Contact</a> <br />
+ <a href="/portal/support/documentation">Documentation</a>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="home-panel" id="manager">
+ <table>
+ <tr>
+ <td>INSTITUTION</td>
+ <td>SLICES</td>
+ <td>REQUESTS</td>
+ </tr>
+ <tr>
+ <td><a href="/portal/institution"><img src="{{ STATIC_URL }}img/icon_authority_color.png" alt="" /></a></td>
+ <td><a href="/portal/institution#slices"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a></td>
+ <td><a href="/portal/validate"><img src="{{ STATIC_URL }}img/icon_testbed_color.png" alt="" /></a></td>
+ </tr>
+ </table>
+ <table>
+ <tr class="bar1">
+ {% if person %}
+ <td class="logged-in">
+ <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
+ {% else %}
+ <td>
+ {% include 'fibre__widget-login-manager.html' %}
+ {% include 'fibre__widget-login-ldap-manager.html' %}
+ {% endif %}
+ </td>
+ <td>
+ {% if person %}
+ <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create a Slice</button>
+ {% endif %}
+ </td>
+ <td class="support">
+ {% if person %}
+ <button id="validaterequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Validate Requests</button>
+ {% endif %}
+ </td>
+ </tr>
+ </table>
+ </div>
+</div>
+<div id="footer">
+ FIBRE - Future Internet testbeds / experimentation between BRazil and Europe
+</div>
+<script>
+ $(document).ready(function() {
+ $('a.home-tab').click(function() {
+ $('ul.nav-tabs li').removeClass('active');
+ $(this).parent().addClass('active');
+ $('div.home-panel').hide();
+ $('div#'+$(this).data('panel')).show();
+ });
+ $('button#validaterequestbtn').click(function() {
+ window.location="/portal/validate/";
+ });
+ $('button#ticketbtn').click(function() {
+ window.location="/portal/contact/";
+ });
+ $('button#slicerequestbtn').click(function() {
+ window.location="/portal/slice_request/";
+ });
+
+ {% if person %}
+ $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
+ var items = [];
+ $.each( data[0].slices, function(i, val) {
+ items.push( "<li><a href=\"/slice/"+val+"\">" + val + "</a></li>" );
+ });
+
+ $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
+
+ });
+ {% endif %}
+ });
+</script>
+{% endblock %}
--- /dev/null
+{% extends "layout_wide.html" %}
+
+{% block head %}
+<script src="{{ STATIC_URL }}js/onelab_slice-resource-view.js"></script>
+{% endblock %}
+
+{% block content %}
+ <div class="col-md-2">
+ <div id="select-platform" class="list-group">
+ </div>
+
+ <ul class="list-group">
+ <li class="list-group-item">Filter: CPU</li>
+ <li class="list-group-item">Filter: Interface</li>
+ <li class="list-group-item">...</li>
+ <li class="list-group-item">...</li>
+ <li class="list-group-item">...</li>
+ </ul>
+
+ </div>
+ <div class="col-md-10">
+ <div class="row">
+ {% include theme|add:"_widget-slice-sections.html" %}
+ </div>
+ <div class="row slice-pending">
+ <ul class="nav nav-pills">
+ <li><a href="">Unreserved</a></li>
+ <li><a href="">Reserved</a></li>
+ <li><a href="">Pending<span class="badge">42</span></a></li>
+ <li>
+ <button type="button" class="btn btn-primary apply">Apply</button>
+ <button type="button" class="btn btn-default clear">Clear</button>
+ </li>
+ </ul>
+ </div>
+ <div class="row">
+ <ul class="nav nav-tabs">
+ <li class="active"><a href="#">Resources</a></li>
+ <li><a href="#"></a></li>
+ <li><a href="#"></a></li>
+ </ul>
+ </div>
+ <table cellpadding="0" cellspacing="0" border="0" class="table" id="objectList"></table>
+ </div>
+{% endblock %}
\ No newline at end of file
--- /dev/null
+{% extends "layout_wide.html" %}
+
+
+{% block content %}
+ <div class="col-md-2">
+ <div id="select-platform" class="list-group">
+ </div>
+
+ <ul class="list-group">
+ <li class="list-group-item">Filter: authority</li>
+ <li class="list-group-item">Filter: slice</li>
+ <li class="list-group-item">...</li>
+ <li class="list-group-item">...</li>
+ <li class="list-group-item">...</li>
+ </ul>
+
+ </div>
+ <div class="col-md-10">
+ <div class="row">
+ {% include theme|add:"_widget-slice-sections.html" %}
+ </div>
+ <div class="row slice-pending">
+ <ul class="nav nav-pills">
+ <li><a href="">All users</a></li>
+ <li><a href="">Users in Slice</a></li>
+ <li><a href="">Pending<span class="badge">42</span></a></li>
+ <li>
+ <button type="button" class="btn btn-primary apply">Apply</button>
+ <button type="button" class="btn btn-default clear">Clear</button>
+ </li>
+ </ul>
+ </div>
+ <div class="row">
+ <ul class="nav nav-tabs">
+ <li class="active"><a href="#">Users</a></li>
+ <li><a href="#"></a></li>
+ <li><a href="#"></a></li>
+ </ul>
+ </div>
+ <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Useres" /></div>
+ <div id="user-tab-loaded" style="display:none;">
+ <table id="user-tab">
+ <tr>
+ <th>+/-</th>
+ <th>Email</th>
+ <th>user_hrn</th>
+ <th>Enabled</th>
+ </tr>
+ </table>
+ </div>
+<script>
+ $(document).ready(function() {
+ $.post("/rest/user/",{'filters':{'parent_authority':'ple.upmc'}}, function( data ) {
+ var list_users = [];
+ var table_users = [];
+ /*
+ "enabled", "keys", "parent_authority", "user_first_name", "user_last_name", "user_phone", "user_hrn", "slice", "user_email"
+ */
+ $.each( data, function( key, val ) {
+ list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
+ user_row = "<tr>";
+ // checking the box for the users that belong to the selected slice
+ var flag_checkbox = 0;
+ for(var data in val.slice) {
+ var element = val.slice[data];
+ console.log("element");
+ console.log(element);
+ for(var key in element) {
+ var value = element[key];
+ if (value == 'ple.upmc.myslicedemo'){
+ console.log("found!!");
+ flag_checkbox = 1;
+ user_row += "<td><input type='checkbox' checked='True'></td>";
+ }
+
+ }
+ }
+ if(flag_checkbox != 1){
+ user_row += "<td><input type='checkbox'></td>";
+ }
+ user_row += "<td>"+val.user_email+"</td>";
+ user_row += "<td>"+val.user_hrn+"</td>";
+ user_row += "<td>"+val.enabled+"</td>";
+ user_row += "</tr>";
+ table_users.push(user_row);
+
+ });
+ $("table#user-tab tr:last").after(table_users.join( "" ));
+ $("div#user-tab-loaded").css("display","block");
+ $("div#user-tab-loading").css("display","none");
+ });
+ });
+</script>
+
+{% endblock %}
--- /dev/null
+{% extends "layout_wide.html" %}
+
+{% block content %}
+ <div class="col-md-2"></div>
+ <div class="col-md-10">
+ <div class="row">
+ {% include theme|add:"_widget-slice-sections.html" %}
+ </div>
+ </div>
+
+ <div class="col-md-2"></div>
+ <div class="col-md-10">
+ <br>
+ <br>
+ <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+ <div id="slice-tab-loaded" style="display:none;">
+ <table id="slice-tab">
+ </table>
+ </div>
+ </div>
+
+<script>
+ $(document).ready(function() {
+ $.post("/rest/slice/",{'filters':{'slice_hrn':'{{slice}}'}}, function( data ) {
+ var table_slices = [];
+ /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "user", "slice_urn", "slice_expires" */
+ $.each( data, function( key, val ) {
+ if(val.nodes=="undefined" || val.nodes==null){
+ nodes_length=0;
+ }else{
+ nodes_length=val.nodes.length;
+ }
+
+ if(val.user=="undefined" || val.user==null){
+ user_length=0;
+ }else{
+ user_length=val.user.length;
+ }
+
+ if(val.slice_url=="undefined" || val.slice_url==null){
+ slice_url="";
+ }else{
+ slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
+ }
+
+ slice_row = "<tr><td><b>Description:</b></td><td>"+val.slice_description+"</td></tr>";
+ slice_row += "<tr><td><b>url:</b></td><td><a href='"+val.slice_url+" target='_blank'>"+val.slice_url+"</a></td></tr>";
+ slice_row += "<tr><td><b>users:</b></td><td>"+user_length+"</td></tr>";
+ slice_row += "<tr><td><b>resources:</b></td><td>"+nodes_length+"</td></tr>";
+ slice_row += "<tr><td><b>created:</b></td><td>"+val.created+"</td></tr>";
+ slice_row += "<tr><td><b>last update:</b></td><td>"+val.last_updated+"</td></tr>";
+ slice_row += "<tr><td><b>expires:</b></td><td>"+val.slice_expires+"</td></tr>";
+ table_slices.push(slice_row);
+ });
+ $("table#slice-tab").html(table_slices.join( "" ));
+ $("div#slice-tab-loaded").css("display","block");
+ $("div#slice-tab-loading").css("display","none");
+ });
+ });
+</script>
+{% endblock %}
--- /dev/null
+{% extends "layout_wide.html" %}
+
+{% block content %}
+ <div class="col-md-2"></div>
+ <div class="col-md-10">
+ <div class="row">
+ {% include theme|add:"_widget-slice-sections.html" %}
+ </div>
+ <div class="row">
+ <ul class="nav nav-tabs">
+ <li class="active"><a href="#">Testbeds</a></li>
+ <li><a href="#"></a></li>
+ <li><a href="#"></a></li>
+ </ul>
+ </div>
+ <table cellpadding="0" cellspacing="0" border="0" class="table" id="testbedList"></table>
+ </div>
+{% endblock %}
\ No newline at end of file
--- /dev/null
+<div class="col-md-8 slice-sections">
+ <ul class="nav nav-pills nav-justified">
+ <li {% if section == 'slice' %}class="active"{% endif %}><a href="/slice/{{ slice }}/">{{ slice }}</a></li>
+ <li {% if section == 'testbeds' %}class="active"{% endif %}><a href="/testbeds/{{ slice }}/">Testbeds</a></li>
+ <li {% if section == 'resources' %}class="active"{% endif %}><a href="/resources/{{ slice }}/">Resources</a></li>
+ <li {% if section == 'users' %}class="active"{% endif %}><a href="/users/{{ slice }}/">Users</a></li>
+ <li><a href="">Statistics</a></li>
+ <li><a href="">Measurements</a></li>
+ </ul>
+</div>
+<div class="col-md-4 slice-experiment">
+ <a href="/portal/experiment"><button type="button" class="btn btn-default">Experiment</button></a>
+</div>
@property
def theme(self):
self.config = ConfigEngine()
+ print self.config
if self.config.myslice.theme :
return self.config.myslice.theme
def template(self):
# Load a template from the theme directory if it exists
# else load it from the common templates dir
- print "THEME = ",self.theme
+ print "THEME 00 = ",self.theme
print "TEMPLATE = ",self.template_name
print "TEMPLATE_DIRS = ",TEMPLATE_DIRS
filename = self.theme + '_' + self.template_name
print packages
# Avoid troubles : clean /usr/share/unfold/
-shutil.rmtree('/usr/share/unfold/')
+#shutil.rmtree('/usr/share/unfold/')
setup(packages = packages,
# xxx somehow this does not seem to show up in debian packaging
{# This is required by insert_above #}{% insert_handler %}<!DOCTYPE html>
<html lang="en"><head>
-<title>OneLab - {{ section }}</title>
+<title>FIBRE - {{ section }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/static/img/myslice-icon.png">
{# This is where insert_str will end up #}{% media_container prelude %}
-<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js" type="text/javascript"></script>
+<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js" type="text/javascript"></script>
<!-- <script type="text/javascript">{{ STATIC_URL }}js/ui.widget.js</script> -->
<script src="{{ STATIC_URL }}js/jquery.notify.js" type="text/javascript"></script>
<link rel='stylesheet' href='{{ STATIC_URL }}css/ui.notify.css' type='text/css' />