132
133
} /* namespace */
134
bool plugin::Authorization::isAuthorized(identifier::User::const_reference user_ctx,
135
identifier::Schema::const_reference schema_identifier,
138
/* If we never loaded any authorization plugins, just return true */
139
if (authorization_plugins.empty())
142
/* Use find_if instead of foreach so that we can collect return codes */
143
std::vector<plugin::Authorization *>::const_iterator iter=
144
std::find_if(authorization_plugins.begin(),
145
authorization_plugins.end(),
146
RestrictDbFunctor(user_ctx, schema_identifier));
150
* If iter is == end() here, that means that all of the plugins returned
151
* false, which means that that each of them believe the user is authorized
152
* to view the resource in question.
154
if (iter != authorization_plugins.end())
158
error::access(user_ctx, schema_identifier);
165
bool plugin::Authorization::isAuthorized(drizzled::identifier::User::const_reference user_ctx,
166
identifier::Table::const_reference table_identifier,
169
/* If we never loaded any authorization plugins, just return true */
170
if (authorization_plugins.empty())
173
/* Use find_if instead of foreach so that we can collect return codes */
174
std::vector<plugin::Authorization *>::const_iterator iter=
175
std::find_if(authorization_plugins.begin(),
176
authorization_plugins.end(),
177
RestrictTableFunctor(user_ctx, table_identifier));
180
* If iter is == end() here, that means that all of the plugins returned
181
* false, which means that that each of them believe the user is authorized
182
* to view the resource in question.
184
if (iter != authorization_plugins.end())
188
error::access(user_ctx, table_identifier);
195
bool plugin::Authorization::isAuthorized(drizzled::identifier::User::const_reference user_ctx,
196
Session::const_reference session,
199
/* If we never loaded any authorization plugins, just return true */
200
if (authorization_plugins.empty())
203
// To make sure we hold the user structure we need to have a shred_ptr so
204
// that we increase the count on the object.
205
drizzled::identifier::User::const_shared_ptr session_ctx= session.user();
208
/* Use find_if instead of foreach so that we can collect return codes */
209
std::vector<plugin::Authorization *>::const_iterator iter=
210
std::find_if(authorization_plugins.begin(),
211
authorization_plugins.end(),
212
RestrictProcessFunctor(user_ctx, *session_ctx));
215
* If iter is == end() here, that means that all of the plugins returned
216
* false, which means that that each of them believe the user is authorized
217
* to view the resource in question.
220
if (iter != authorization_plugins.end())
224
my_error(ER_KILL_DENIED_ERROR, MYF(0), session.thread_id);
232
void plugin::Authorization::pruneSchemaNames(drizzled::identifier::User::const_reference user_ctx,
233
identifier::Schema::vector &set_of_schemas)
135
bool plugin::Authorization::isAuthorized(const SecurityContext &user_ctx,
136
SchemaIdentifier &schema_identifier,
139
/* If we never loaded any authorization plugins, just return true */
140
if (authorization_plugins.empty())
143
/* Use find_if instead of foreach so that we can collect return codes */
144
vector<plugin::Authorization *>::const_iterator iter=
145
find_if(authorization_plugins.begin(),
146
authorization_plugins.end(),
147
RestrictDbFunctor(user_ctx, schema_identifier));
151
* If iter is == end() here, that means that all of the plugins returned
152
* false, which means that that each of them believe the user is authorized
153
* to view the resource in question.
155
if (iter != authorization_plugins.end())
160
schema_identifier.getSQLPath(path);
162
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
163
user_ctx.getUser().c_str(),
164
user_ctx.getIp().c_str(),
172
bool plugin::Authorization::isAuthorized(const SecurityContext &user_ctx,
173
TableIdentifier &table,
176
/* If we never loaded any authorization plugins, just return true */
177
if (authorization_plugins.empty())
180
/* Use find_if instead of foreach so that we can collect return codes */
181
vector<plugin::Authorization *>::const_iterator iter=
182
find_if(authorization_plugins.begin(),
183
authorization_plugins.end(),
184
RestrictTableFunctor(user_ctx, table));
187
* If iter is == end() here, that means that all of the plugins returned
188
* false, which means that that each of them believe the user is authorized
189
* to view the resource in question.
191
if (iter != authorization_plugins.end())
196
table.getSQLPath(path);
198
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
199
user_ctx.getUser().c_str(),
200
user_ctx.getIp().c_str(),
208
bool plugin::Authorization::isAuthorized(const SecurityContext &user_ctx,
209
const Session *session,
212
const SecurityContext &session_ctx= session->getSecurityContext();
214
/* If we never loaded any authorization plugins, just return true */
215
if (authorization_plugins.empty())
218
/* Use find_if instead of foreach so that we can collect return codes */
219
vector<plugin::Authorization *>::const_iterator iter=
220
find_if(authorization_plugins.begin(),
221
authorization_plugins.end(),
222
RestrictProcessFunctor(user_ctx, session_ctx));
225
* If iter is == end() here, that means that all of the plugins returned
226
* false, which means that that each of them believe the user is authorized
227
* to view the resource in question.
230
if (iter != authorization_plugins.end())
234
my_error(ER_KILL_DENIED_ERROR, MYF(0), session->thread_id);
241
void plugin::Authorization::pruneSchemaNames(const SecurityContext &user_ctx,
242
SchemaIdentifier::vector &set_of_schemas)
235
244
/* If we never loaded any authorization plugins, just return true */
236
245
if (authorization_plugins.empty())
239
set_of_schemas.erase(std::remove_if(set_of_schemas.begin(),
240
set_of_schemas.end(),
241
PruneSchemaFunctor(user_ctx)),
248
set_of_schemas.erase(remove_if(set_of_schemas.begin(),
249
set_of_schemas.end(),
250
PruneSchemaFunctor(user_ctx)),
242
251
set_of_schemas.end());