Skip to content

Instantly share code, notes, and snippets.

@ManivannanMurugavel
Created March 10, 2019 07:04
Show Gist options
  • Save ManivannanMurugavel/570c75386ad3e0b93d6fe4d9448b6e02 to your computer and use it in GitHub Desktop.
Save ManivannanMurugavel/570c75386ad3e0b93d6fe4d9448b6e02 to your computer and use it in GitHub Desktop.
Generic grafana oauth login athentication page
<?php
$state = $_GET['state'];
$state = urlencode($state);
$url = "http://localhost:3000/login/generic_oauth?state=".$state."&code=cc536d98d27750394a87ab9d057016e636a8ac31";
$user_email = $_COOKIE["user_email"];
if($user_email != "")
{
$myfile = fopen("userinfo/newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile, $user_email);
fclose($myfile);
header("Location: ".$url);
}
if(isset($_POST["submit"])){
$myfile = fopen("userinfo/newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile, $_POST['email']);
fclose($myfile);
setcookie("user_email", $_POST['email'], time()+60, "/");
header("Location: ".$_POST['url']);
}
?>
<form method="POST">
<input type="email" name="email">
<input type="hidden" name="url" value="<?php echo $url; ?>">
<input type="submit" name="submit">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment