355c42cb30
Conflicts: include/config.php update.php
728 lines
30 KiB
PHP
728 lines
30 KiB
PHP
<?php
|
|
|
|
//ini_set('display_errors', 1);
|
|
//error_reporting(E_ALL | E_STRICT);
|
|
|
|
// Regex to filter out the client identifier
|
|
// (described in Section 2 of IETF draft)
|
|
// IETF draft does not prescribe a format for these, however
|
|
// I've arbitrarily chosen alphanumeric strings with hyphens and underscores, 3-12 characters long
|
|
// Feel free to change.
|
|
define("REGEX_CLIENT_ID", "/^[a-z0-9-_]{3,12}$/i");
|
|
|
|
// Used to define the name of the OAuth access token parameter (POST/GET/etc.)
|
|
// IETF Draft sections 5.2 and 5.3 specify that it should be called "oauth_token"
|
|
// but other implementations use things like "access_token"
|
|
// I won't be heartbroken if you change it, but it might be better to adhere to the spec
|
|
define("OAUTH_TOKEN_PARAM_NAME", "oauth_token");
|
|
|
|
// Client types (for client authorization)
|
|
//define("WEB_SERVER_CLIENT_TYPE", "web_server");
|
|
//define("USER_AGENT_CLIENT_TYPE", "user_agent");
|
|
//define("REGEX_CLIENT_TYPE", "/^(web_server|user_agent)$/");
|
|
define("ACCESS_TOKEN_AUTH_RESPONSE_TYPE", "token");
|
|
define("AUTH_CODE_AUTH_RESPONSE_TYPE", "code");
|
|
define("CODE_AND_TOKEN_AUTH_RESPONSE_TYPE", "code-and-token");
|
|
define("REGEX_AUTH_RESPONSE_TYPE", "/^(token|code|code-and-token)$/");
|
|
|
|
// Grant Types (for token obtaining)
|
|
define("AUTH_CODE_GRANT_TYPE", "authorization-code");
|
|
define("USER_CREDENTIALS_GRANT_TYPE", "basic-credentials");
|
|
define("ASSERTION_GRANT_TYPE", "assertion");
|
|
define("REFRESH_TOKEN_GRANT_TYPE", "refresh-token");
|
|
define("NONE_GRANT_TYPE", "none");
|
|
define("REGEX_TOKEN_GRANT_TYPE", "/^(authorization-code|basic-credentials|assertion|refresh-token|none)$/");
|
|
|
|
/* Error handling constants */
|
|
|
|
// HTTP status codes
|
|
define("ERROR_NOT_FOUND", "404 Not Found");
|
|
define("ERROR_BAD_REQUEST", "400 Bad Request");
|
|
|
|
// TODO: Extend for i18n
|
|
|
|
// "Official" OAuth 2.0 errors
|
|
define("ERROR_REDIRECT_URI_MISMATCH", "redirect-uri-mismatch");
|
|
define("ERROR_INVALID_CLIENT_CREDENTIALS", "invalid-client-credentials");
|
|
define("ERROR_UNAUTHORIZED_CLIENT", "unauthorized-client");
|
|
define("ERROR_USER_DENIED", "access-denied");
|
|
define("ERROR_INVALID_REQUEST", "invalid-request");
|
|
define("ERROR_INVALID_CLIENT_ID", "invalid-client-id");
|
|