Skip to content

Commit c979837

Browse files
committed
Doxygen: documented the password validation service and the keyring service
1 parent a894d53 commit c979837

File tree

5 files changed

+174
-36
lines changed

5 files changed

+174
-36
lines changed

include/mysql/plugin_validate_password.h

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -24,26 +24,47 @@
2424
#include <mysql/plugin.h>
2525
#define MYSQL_VALIDATE_PASSWORD_INTERFACE_VERSION 0x0100
2626

27-
/*
28-
The descriptor structure for the plugin, that is referred from
29-
st_mysql_plugin.
30-
*/
31-
3227
typedef void* mysql_string_handle;
3328

29+
/**
30+
This plugin type defines interface that the server uses to
31+
enforce a password policy.
32+
33+
The policy is enfoced through st_mysql_validate_password::validate_password()
34+
that answers the question of whether this password is good enough or not.
35+
36+
There's one auxilary functon
37+
st_mysql_validate_password::get_password_strength() that can be used by
38+
password changing UIs to display a password strength meter as the user enters
39+
a password.
40+
41+
Since plugins may need that functionality there's a plugin service
42+
@ref mysql_password_policy_service_st exposing
43+
it to other plugins.
44+
45+
There also is a default password policy plugin
46+
"validate_password" built into the server binary that
47+
implements this plugin API.
48+
49+
@sa mysql_password_policy_service_st
50+
*/
3451
struct st_mysql_validate_password
3552
{
3653
int interface_version;
37-
/*
38-
This function retuns TRUE for passwords which satisfy the password
39-
policy (as choosen by plugin variable) and FALSE for all other
40-
password
54+
/**
55+
Checks if a password is valid by the password policy
56+
57+
@param password The password to validate
58+
@retval TRUE password meets the password validation plugin policy
59+
@retval FALSE password does not meet the validation policy
4160
*/
4261
int (*validate_password)(mysql_string_handle password);
43-
/*
44-
This function returns the password strength (0-100) depending
45-
upon the policies
62+
/**
63+
Calculates the strength of a password in the scale of 0 to 100.
64+
65+
@param password The password to evaluate the strength of
66+
@return The strength of the password (0-100)
4667
*/
4768
int (*get_password_strength)(mysql_string_handle password);
4869
};
49-
#endif
70+
#endif

include/mysql/service_mysql_keyring.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,69 @@
1616
#ifndef MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED
1717
#define MYSQL_SERVICE_MYSQL_PLUGIN_KEYRING_INCLUDED
1818

19+
/**
20+
@file include/mysql/service_mysql_keyring.h
21+
*/
22+
23+
1924
#ifdef __cplusplus
2025
extern "C" {
2126
#endif
2227

28+
/**
29+
@ingroup group_ext_plugin_services
30+
31+
This service allows plugins to interact with key store backends.
32+
33+
A key currently is a blob of binary data, defined by a string
34+
key type, that's meanigfull to the relevant backend.
35+
Typical key_type values include "AES", "DES", "DSA" etc.
36+
There's no length in the type, since it's defined by the number of bytes
37+
the key takes.
38+
39+
A key is uniquely identified by the key_id and the user_id values, i.e.
40+
all keys are assigned to a particular user.
41+
There's only one exception to that: a single category for instance keys
42+
that are not associated with any particular user id. This is signified
43+
to the APIs by supplying NULL for user_id.
44+
Plugins would typically pass user accounts to the user_id parameter, or
45+
NULL if there's no user account to associate the key with.
46+
47+
Not all backends must implement all of the functions defined
48+
in this interface.
49+
50+
The plugin service is a "bridge service", i.e. facade with no
51+
real functionality that just calls the actual keyring plugin APIs.
52+
This is needed to allow other plugins to call into the keyring
53+
plugins and thus overcome the limitation that only the server
54+
can call plugins.
55+
56+
@sa st_mysql_keyring
57+
*/
2358
extern struct mysql_keyring_service_st
2459
{
60+
/**
61+
Stores a key into the keyring.
62+
@sa my_key_store, st_mysql_keyring::mysql_key_store
63+
*/
2564
int (*my_key_store_func)(const char *, const char *, const char *,
2665
const void *, size_t);
66+
/**
67+
Receives a key from the keyring.
68+
@sa my_key_fetch, st_mysql_keyring::mysql_key_fetch
69+
*/
2770
int (*my_key_fetch_func)(const char *, char **, const char *, void **,
2871
size_t *);
72+
73+
/**
74+
Removes a key from the keyring.
75+
@sa my_key_remove, st_mysql_keyring::mysql_key_remove
76+
*/
2977
int (*my_key_remove_func)(const char *, const char *);
78+
/**
79+
Generates a new key inside the keyring backend
80+
@sa my_key_generate, st_mysql_keyring::mysql_key_generate
81+
*/
3082
int (*my_key_generate_func)(const char *, const char *, const char *,
3183
size_t);
3284
} *mysql_keyring_service;

include/mysql/service_mysql_password_policy.h

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -18,30 +18,39 @@
1818

1919
/**
2020
@file include/mysql/service_mysql_password_policy.h
21-
This service provides functions to validate password, check for strength
22-
of password based on common policy.
23-
24-
SYNOPSIS
25-
my_validate_password_policy() - function to validate password
26-
based on defined policy
27-
const char* buffer holding the password value
28-
unsigned int buffer length
29-
30-
my_calculate_password_strength() - function to calculate strength
31-
of the password based on the policies defined.
32-
const char* buffer holding the password value
33-
unsigned int buffer length
34-
35-
Both the service function returns 0 on SUCCESS and 1 incase input password does not
36-
match against the policy rules defined.
21+
22+
Definitions for the password validation service
3723
*/
3824

3925
#ifdef __cplusplus
4026
extern "C" {
4127
#endif
4228

29+
/**
30+
@ingroup group_ext_plugin_services
31+
32+
This service allows plugins to validate passwords based on a common policy.
33+
34+
This is a "bridge service", i.e. facade with no
35+
real functionality that just calls the actual password validation plugin
36+
APIs. This serive is needed by other plugins to call into the password
37+
validation plugins and thus overcome the limitation that only the server
38+
can call plugins.
39+
40+
@sa st_mysql_validate_password
41+
*/
4342
extern struct mysql_password_policy_service_st {
43+
/**
44+
Validates a password.
45+
46+
@sa my_validate_password_policy, st_mysql_validate_password::validate_password
47+
*/
4448
int (*my_validate_password_policy_func)(const char *, unsigned int);
49+
/**
50+
Evaluates the strength of a password in a scale 0-100
51+
52+
@sa my_calculate_password_strength, st_mysql_validate_password::get_password_strength
53+
*/
4554
int (*my_calculate_password_strength_func)(const char *, unsigned int);
4655
} *mysql_password_policy_service;
4756

sql/auth/password_policy_service.cc

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or
44
modify it under the terms of the GNU General Public License as
@@ -24,19 +24,32 @@
2424
#include "sql_plugin.h"
2525

2626

27+
/**
28+
Static name of the built in plugin used by mysql_password_policy_service_st
29+
for password validation.
30+
*/
2731
LEX_CSTRING validate_password_plugin= {
2832
C_STRING_WITH_LEN("validate_password")
2933
};
3034

3135
/**
32-
Validate the input password based on defined policies.
36+
Invoke the plugin to validate the input password.
37+
38+
Implementation of a plugin service @ref mysql_password_policy_service_st
39+
method.
40+
Calls the @ref validate_password_plugin plugin's @ref
41+
st_mysql_validate_password::validate_password method.
42+
Constructs a temporary binary @ref String object out of the password
43+
supplied.
3344
3445
@param password password which needs to be validated against the
3546
defined policies
3647
@param password_len length of password
3748
38-
@retval 0 ok
39-
@retval 1 ERROR;
49+
@retval 0 Password OK
50+
@retval 1 Password incompatible with policy
51+
52+
@sa st_mysql_validate_password, mysql_password_policy_service_st::my_validate_password_policy_func
4053
*/
4154

4255
int my_validate_password_policy(const char *password, unsigned int password_len)
@@ -68,7 +81,25 @@ int my_validate_password_policy(const char *password, unsigned int password_len)
6881
}
6982

7083

71-
/* called when new user is created or exsisting password is changed */
84+
/**
85+
Invoke the plugin to evalue the strength of a password.
86+
87+
Implementation of a plugin service @ref mysql_password_policy_service_st
88+
method.
89+
Typically called when new user is created or exsisting password is changed.
90+
Calls the @ref validate_password_plugin plugin's @ref
91+
st_mysql_validate_password::get_password_strength method.
92+
Constructs a temporary binary @ref String object out of the password
93+
supplied.
94+
95+
@param password password which needs to be validated against the
96+
defined policies
97+
@param password_len length of password
98+
99+
@return password strength score (0-100)
100+
101+
@sa st_mysql_validate_password, mysql_password_policy_service_st::my_calculate_password_strength_func
102+
*/
72103
int my_calculate_password_strength(const char *password, unsigned int password_len)
73104
{
74105
int res= 0;

sql/keyring_service.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ static my_bool key_generate(THD *thd, plugin_ref plugin, void *arg)
105105
return TRUE;
106106
}
107107

108+
/**
109+
Iterates over all active keyring plugins and calls the mysql_key_fetch API
110+
for the first one found.
111+
112+
@sa st_mysql_keyring::mysql_key_fetch, mysql_keyring_service_st
113+
*/
108114
int my_key_fetch(const char *key_id, char **key_type, const char *user_id,
109115
void **key, size_t *key_len)
110116
{
@@ -118,6 +124,13 @@ int my_key_fetch(const char *key_id, char **key_type, const char *user_id,
118124
return key_data.result;
119125
}
120126

127+
128+
/**
129+
Iterates over all active keyring plugins calls the mysql_key_store API
130+
for the first one found.
131+
132+
@sa st_mysql_keyring::mysql_key_store, mysql_keyring_service_st
133+
*/
121134
int my_key_store(const char *key_id, const char *key_type, const char *user_id,
122135
const void *key, size_t key_len)
123136
{
@@ -131,6 +144,12 @@ int my_key_store(const char *key_id, const char *key_type, const char *user_id,
131144
return key_data.result;
132145
}
133146

147+
/**
148+
Iterates over all active keyring plugins and calls the mysql_key_remove API
149+
for the first one found.
150+
151+
@sa st_mysql_keyring::mysql_key_remove, mysql_keyring_service_st
152+
*/
134153
int my_key_remove(const char *key_id, const char *user_id)
135154
{
136155
Key_data key_data;
@@ -140,6 +159,12 @@ int my_key_remove(const char *key_id, const char *user_id)
140159
return key_data.result;
141160
}
142161

162+
/**
163+
Iterates over all active keyring plugins and calls the mysql_key_generate API
164+
for the first one found.
165+
166+
@sa st_mysql_keyring::mysql_key_generate, mysql_keyring_service_st
167+
*/
143168
int my_key_generate(const char *key_id, const char *key_type,
144169
const char *user_id, size_t key_len)
145170
{

0 commit comments

Comments
 (0)