auth:ning
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
auth:ning [2013-03-01 09:48] – [Installation] 210.55.240.39 | auth:ning [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Ning authentication | ||
- | ===== What does it do? ===== | ||
- | |||
- | It authenticates users by logging into a Ning community. | ||
- | |||
- | ===== Installation ===== | ||
- | |||
- | Paste the code into " | ||
- | * myningnetwork.ning.com to your domain | ||
- | * first@example.com and second@example.com to the admin users email | ||
- | |||
- | Then add the following line to " | ||
- | $conf[' | ||
- | |||
- | Make sure that the file does not contain empty lines at the beginning and at the end, otherwise you will get PHP warnings. | ||
- | |||
- | **NOTE** | ||
- | |||
- | Username and password are sent as plaintext. | ||
- | |||
- | function checkDomain($domain) { | ||
- | $url = " | ||
- | $curl = curl_init($url); | ||
- | |||
- | curl_setopt ($curl, CURLOPT_USERAGENT, | ||
- | |||
- | |||
- | ===== Code ===== | ||
- | |||
- | <file php ning.class.php> | ||
- | <?php | ||
- | /** | ||
- | * auth/ | ||
- | * | ||
- | * ning authorization class | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | |||
- | define(' | ||
- | require_once(DOKU_AUTH . '/ | ||
- | |||
- | class NingConfig { | ||
- | function getDomain() { | ||
- | return ' | ||
- | } | ||
- | |||
- | function getAdmins() { | ||
- | return array( | ||
- | ' | ||
- | ' | ||
- | ); | ||
- | } | ||
- | } | ||
- | |||
- | /** | ||
- | | ||
- | | ||
- | */ | ||
- | class NingIdApi { | ||
- | /** | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | */ | ||
- | function checkDomain($domain) { | ||
- | $url = " | ||
- | $curl = curl_init($url); | ||
- | curl_setopt($curl, | ||
- | $result = curl_exec($curl); | ||
- | if ($result && is_array($info = unserialize($result)) && $info[' | ||
- | return true; | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | function authorize($domain, | ||
- | $url = " | ||
- | $curl = curl_init($url); | ||
- | curl_setopt($curl, | ||
- | curl_setopt($curl, | ||
- | curl_setopt($curl, | ||
- | curl_setopt($curl, | ||
- | $result = curl_exec($curl); | ||
- | if ($result && is_array($info = unserialize($result)) && count($info) && $info[' | ||
- | return $info; | ||
- | } | ||
- | return NULL; | ||
- | } | ||
- | } | ||
- | |||
- | class auth_ning extends auth_basic { | ||
- | var $ning_name; | ||
- | var $ning_email; | ||
- | var $ning_grps; | ||
- | |||
- | /** | ||
- | * Check user+password [ MUST BE OVERRIDDEN ] | ||
- | * | ||
- | * Checks if the given user exists and the given | ||
- | * plaintext password is correct | ||
- | * | ||
- | * May be ommited if trustExternal is used. | ||
- | * | ||
- | * @author | ||
- | * @return | ||
- | */ | ||
- | function checkPass($user, | ||
- | if ($info = NingIdApi:: | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | $this-> | ||
- | if (in_array($user, | ||
- | $this-> | ||
- | } | ||
- | |||
- | return true; | ||
- | } | ||
- | |||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Return user info [ MUST BE OVERRIDDEN ] | ||
- | * | ||
- | * Returns info about the given user needs to contain | ||
- | * at least these fields: | ||
- | * | ||
- | * name string | ||
- | * mail string | ||
- | * grps array list of groups the user is in | ||
- | * | ||
- | * @author | ||
- | * @return | ||
- | */ | ||
- | function getUserData($user) { | ||
- | return array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ); | ||
- | } | ||
- | } | ||
- | |||
- | |||
- | ?> | ||
- | </ |
auth/ning.1362127728.txt.gz · Last modified: 2013-03-01 09:48 by 210.55.240.39