コード例 #1
0
ファイル: callback.php プロジェクト: cvweiss/projectbase
 private function getProvider()
 {
     $auth = Config::getInstance()->get("oauth2");
     $google = $auth['google'];
     $provider = new \League\OAuth2\Client\Provider\Google(['clientId' => $google['client_id'], 'clientSecret' => $google['client_secret'], 'redirectUri' => $google['redirect_uris'][0]]);
     return $provider;
 }
コード例 #2
0
ファイル: login.php プロジェクト: cvweiss/projectbase
 public function doGet($view, $params)
 {
     unset($params);
     $auth = Config::getInstance()->get("oauth2");
     $eve = $auth['eve'];
     $sso = new CrestSSO($eve['client_id'], $eve['client_secret'], $eve['redirect_uris'][0], $eve['scopes'], '/');
     $view->redirect($sso->getLoginURL(Session::getSession()));
 }
コード例 #3
0
ファイル: login.php プロジェクト: cvweiss/projectbase
 public function doGet($view, $params)
 {
     $auth = Config::getInstance()->get("oauth2");
     $google = $auth['google'];
     $provider = new \League\OAuth2\Client\Provider\Google(['clientId' => $google['client_id'], 'clientSecret' => $google['client_secret'], 'redirectUri' => $google['redirect_uris'][0]]);
     // If we don't have an authorization code then get one
     $authUrl = $provider->getAuthorizationUrl();
     Session::getSession()->set('oauth2state', $provider->getState());
     $view->redirect($authUrl);
 }
コード例 #4
0
ファイル: Mongo.php プロジェクト: cvweiss/projectbase
 public static function get(Config $config = null) : Mongo
 {
     if (self::$instance == null || self::$pid != getmypid()) {
         $config = $config ?? Config::getInstance();
         $server = $config->get("mongo_server", "127.0.0.1");
         $port = $config->get("mongo_port", 27017);
         $database = $config->get("mongo_db", "projectbase");
         $manager = new Manager("mongodb://{$server}:{$port}");
         self::$instance = new Mongo($manager, $database);
         self::$pid = getmypid();
     }
     return self::$instance;
 }
コード例 #5
0
ファイル: callback.php プロジェクト: cvweiss/projectbase
 public function doGet($view, $params)
 {
     unset($params);
     $auth = Config::getInstance()->get("oauth2");
     $eve = $auth['eve'];
     $sso = new CrestSSO($eve['client_id'], $eve['client_secret'], $eve['redirect_uris'][0], $eve['scopes'], '/');
     $code = filter_input(INPUT_GET, 'code');
     $state = filter_input(INPUT_GET, 'state');
     $userInfo = $sso->handleCallback($code, $state, Session::getSession());
     $charID = $userInfo['characterID'];
     $id = "auth:eve:" . $charID;
     $user = Mongo::get()->findDoc("users", ['id' => $id], null, true);
     $user->setAll(["id" => $id, "name" => $userInfo['characterName'], "email" => null, "image" => "https://imageserver.eveonline.com/Character/{$charID}_256.jpg", "oauth2" => "eve", "refresh_token" => $userInfo['refreshToken']]);
     $user->save();
     Session::getSession()->set("userID", $id);
     $view->redirect('/', 302);
 }