概念设计:认证(Authentication)与授权(Authorization)

认证(Authentication)

验证我是谁。

授权(Authorization)

在认证(Authorization)后,验证我被允许做什么。

认证(Authentication)接口原型

/**
 * Authenticate user identification.
 *
 * @param name - User name.
 * @param secret - Secret known only to the user.
 *
 * @return Returns authenticated user.
 */
User authenticate(const char* name, const char* secret)
authenticate
验证用户身份

授权(Authorization)接口原型

/**
 * Authorize user to do operation.
 *
 * @param user - User to authorize.
 * @param Operation - Operation to authorize.
 *
 */
void authorize(User user, Operation operation);

/**
 * Deauthorize user to do operation.
 *
 * @param user - User to deauthorize.
 * @param operation - Operation to deauthorize.
 *
 */
void deauthorize(User user, Operation operation);

/**
 * Is user authorized to do operation.
 *
 * @param user - User to check.
 * @param operation - Operation to check.
 *
 * @return Is authorized or not.
 */
bool authorized(User user, Operation operation);
authorize
允许用户操作
deauthorize
禁止用户操作
authorized
检查用户是否允许操作