diff --git a/servecerts/pubkeys.py b/servecerts/pubkeys.py index 2eee576..4a36d56 100644 --- a/servecerts/pubkeys.py +++ b/servecerts/pubkeys.py @@ -23,6 +23,7 @@ def index(): ' JOIN user u ON p.user_id = u.id' ' ORDER BY deleted ASC, revoked ASC, p.created DESC' ).fetchall() + print pubkeys[0] users = db.execute( 'SELECT * FROM user WHERE id = ?', (g.user['id'],) ).fetchone() @@ -154,3 +155,59 @@ def revoke(id): ) db.commit() return redirect(url_for('pubkeys.index')) + +#--------------# +# Certificates # +#--------------# + +@bp.route('//certificates') +@login_required +def certs_index(id): + + print "id : " + str(id) + print "user id: " + str(g.user['id']) + db = get_db() + + user = db.execute( + 'SELECT * FROM user WHERE id = ?', (g.user['id'],) + ).fetchone() + + pubkey = db.execute( + 'SELECT' + ' p.id pid, key_name, fullname, ssh_pubkey, p.created, user_id,' + ' revoked, deleted, fingerprint' + ' FROM pubkeys p' + ' JOIN user u ON p.user_id = u.id' + ' WHERE p.user_id = ? AND p.id = ?' + ' ORDER BY deleted ASC, revoked ASC, p.created DESC', (g.user['id'], id,) + ).fetchone() + + certificates = db.execute( + 'SELECT * FROM certificates c JOIN pubkeys p ON p.id = c.id' + ' JOIN user u ON p.user_id = u.id' + ' WHERE p.id = ?', (id,) + ).fetchall() + + #print "PUBKEY: " + pubkey['fingerprint'] + #print "CERTIFICATES: " + str(certificates) + #print "USERS" + (users) + return render_template('certificates/index.html', pubkey=pubkey, + user=user, certificates=certificates) + + +@bp.route('//certificates/create', methods=('GET', 'POST')) +@login_required +def certs_create(id): + pubkey = get_pubkey(id) + print "Pubkey-ID: " + str(id) + print "create new certificate" + return redirect(url_for('pubkeys.index')) + +@bp.route('//certificates/revoke') +@login_required +def certs_revoke(id): + print "Pubkey-ID: " + id[0] + print "create new certificate" + print "revoke certificate" + return redirect(url_for('pubkeys.index')) + diff --git a/servecerts/templates/certificates/index.html b/servecerts/templates/certificates/index.html index af77491..946f4ca 100644 --- a/servecerts/templates/certificates/index.html +++ b/servecerts/templates/certificates/index.html @@ -3,13 +3,15 @@ {% block header %}

{% block title %} {% if g.user %} - Certificates for Pubkey {{ g.pubkeys['fullname'] }} + Certificates for Pubkey
+ {{ pubkey['key_name'] }} + {% else %} Certificates {% endif %} {% endblock %}

{% if g.user %} - New + New {% endif %} {% endblock %} @@ -22,7 +24,7 @@

Certificate ({{ certificate['id'] }}): {{ certificate['key_id'] }}

{% if g.user['id'] == pubkey['user_id'] %} - Revoke + Revoke {% endif %}

@@ -35,7 +37,7 @@

created on {{ certificate['created'].strftime('%Y-%m-%d') }}

-
+
diff --git a/servecerts/templates/pubkeys/index.html b/servecerts/templates/pubkeys/index.html index dc0faab..669071b 100644 --- a/servecerts/templates/pubkeys/index.html +++ b/servecerts/templates/pubkeys/index.html @@ -20,7 +20,14 @@ {% if not loop.last %}