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())
159
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
160
user_ctx.getUser().c_str(),
161
user_ctx.getIp().c_str(),
162
schema_identifier.getSQLPath().c_str());
169
bool plugin::Authorization::isAuthorized(const SecurityContext &user_ctx,
170
TableIdentifier &table,
173
/* If we never loaded any authorization plugins, just return true */
174
if (authorization_plugins.empty())
177
/* Use find_if instead of foreach so that we can collect return codes */
178
vector<plugin::Authorization *>::const_iterator iter=
179
find_if(authorization_plugins.begin(),
180
authorization_plugins.end(),
181
RestrictTableFunctor(user_ctx, table));
184
* If iter is == end() here, that means that all of the plugins returned
185
* false, which means that that each of them believe the user is authorized
186
* to view the resource in question.
188
if (iter != authorization_plugins.end())
192
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
193
user_ctx.getUser().c_str(),
194
user_ctx.getIp().c_str(),
195
table.getSQLPath().c_str());
202
bool plugin::Authorization::isAuthorized(const SecurityContext &user_ctx,
203
const Session *session,
206
const SecurityContext &session_ctx= session->getSecurityContext();
208
/* If we never loaded any authorization plugins, just return true */
209
if (authorization_plugins.empty())
212
/* Use find_if instead of foreach so that we can collect return codes */
213
vector<plugin::Authorization *>::const_iterator iter=
214
find_if(authorization_plugins.begin(),
215
authorization_plugins.end(),
216
RestrictProcessFunctor(user_ctx, session_ctx));
219
* If iter is == end() here, that means that all of the plugins returned
220
* false, which means that that each of them believe the user is authorized
221
* to view the resource in question.
224
if (iter != authorization_plugins.end())
228
my_error(ER_KILL_DENIED_ERROR, MYF(0), session->thread_id);
235
void plugin::Authorization::pruneSchemaNames(const SecurityContext &user_ctx,
236
SchemaIdentifiers &set_of_schemas)
235
238
/* If we never loaded any authorization plugins, just return true */
236
239
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)),
242
set_of_schemas.erase(remove_if(set_of_schemas.begin(),
243
set_of_schemas.end(),
244
PruneSchemaFunctor(user_ctx)),
242
245
set_of_schemas.end());