Skip to content

Commit

Permalink
Check Auth VNC
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTheGeek committed Jan 26, 2024
1 parent 3f124f9 commit 50ca76c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,16 @@ def check_auth():
logger.info("Authentication check: "+current_user.email+", role: "+current_user.role+", id: "+current_user.id)
return jsonify({'message': 'Authentication check successful'})

@app.route('/check-auth-vnc')
@app.route('/check-auth-vnc?token=<token_url>')
@login_required
def check_auth_vnc():
logger.info("Authentication check: "+current_user.email+", role: "+current_user.role+", id: "+current_user.id)
return jsonify({'message': 'Authentication check successful'}), 200
def check_auth_vnc(token_url):
vm = VM.query.filter_by(vncurl=token_url).first().users_id
if vm.users_id == current_user.id:
logger.info("Authentication check: "+current_user.email+", role: "+current_user.role+", id: "+current_user.id+" to Acces VM VNC : "+vm.name)
return jsonify({'message': 'Authentication check successful'}), 200
else:
logger.warning("Wrong User, "+current_user.id+" want to acces to the VM : "+vm.name)
return jsonify({'message': 'Unauthorized'}), 401


@app.route('/users', methods=['GET'])
Expand Down

0 comments on commit 50ca76c

Please sign in to comment.