1 | <?php |
||
21 | class SsoController extends Controller |
||
22 | { |
||
23 | /** |
||
24 | * Package configuration |
||
25 | * |
||
26 | * @var Collection |
||
27 | */ |
||
28 | protected $config; |
||
29 | |||
30 | /** |
||
31 | * SSOHelper Instance |
||
32 | * |
||
33 | * @var SSOHelper |
||
34 | */ |
||
35 | protected $sso; |
||
36 | |||
37 | /** |
||
38 | * Authenticated user |
||
39 | * |
||
40 | * @var User |
||
41 | */ |
||
42 | protected $user; |
||
43 | |||
44 | /** |
||
45 | * SsoController constructor. |
||
46 | * |
||
47 | * @param Config $config |
||
48 | * @param SSOHelper $sso |
||
49 | */ |
||
50 | public function __construct(Config $config, SSOHelper $sso) |
||
51 | { |
||
52 | $this->loadConfigs($config); |
||
53 | |||
54 | $this->sso = $sso->setSecret($this->config->get('secret')); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Build out the extra parameters to send to Discourse |
||
59 | * |
||
60 | * @return array |
||
61 | */ |
||
62 | protected function buildExtraParameters() |
||
71 | |||
72 | /** |
||
73 | * Make boolean's into string |
||
74 | * |
||
75 | * The Discourse SSO API does not accept 0 or 1 for false or true. You must send |
||
76 | * "false" or "true", so convert any boolean property to the string version. |
||
77 | * |
||
78 | * @param $property |
||
79 | * |
||
80 | * @return string |
||
81 | */ |
||
82 | public function castBooleansToString($property) |
||
90 | |||
91 | /** |
||
92 | * Cache the configs on the object as a collection |
||
93 | * |
||
94 | * The 'user' property will be an array, so go ahead and convert it to a collection |
||
95 | * |
||
96 | * @param Config $config |
||
97 | */ |
||
98 | protected function loadConfigs(Config $config) |
||
103 | |||
104 | /** |
||
105 | * Process the SSO login request from Discourse |
||
106 | * |
||
107 | * @param Request $request |
||
108 | * |
||
109 | * @return mixed |
||
110 | */ |
||
111 | public function login(Request $request) |
||
136 | |||
137 | /** |
||
138 | * Check to see if property is null |
||
139 | * |
||
140 | * @param string $property |
||
141 | * @return bool |
||
142 | */ |
||
143 | public function nullProperty($property) |
||
147 | |||
148 | /** |
||
149 | * Get the property from the user |
||
150 | * |
||
151 | * If a string is passed in, then get it from the user object, otherwise, return what was given |
||
152 | * |
||
153 | * @param string $property |
||
154 | * @return mixed |
||
155 | */ |
||
156 | public function parseUserValue($property) |
||
164 | } |
||
165 |