-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement support for GSSAPI extension RFC 5801 #124
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
from gssapi.raw.cython_types cimport * | ||
from gssapi.raw.oids cimport OID | ||
GSSAPI="BASE" # This ensures that a full module is generated by Cython | ||
|
||
from gssapi.raw.cython_converters cimport c_make_oid | ||
|
||
from gssapi.raw.named_tuples import InquireSASLNameResult | ||
from gssapi.raw.misc import GSSError | ||
|
||
cdef extern from "python_gssapi_ext.h": | ||
OM_uint32 gss_inquire_saslname_for_mech( | ||
OM_uint32 *min_stat, | ||
const gss_OID desired_mech, | ||
gss_buffer_t sasl_mech_name, | ||
gss_buffer_t mech_name, | ||
gss_buffer_t mech_description) nogil | ||
|
||
OM_uint32 gss_inquire_mech_for_saslname( | ||
OM_uint32 *min_stat, | ||
const gss_buffer_t sasl_mech_name, | ||
gss_OID *mech_type) nogil | ||
|
||
|
||
def inquire_saslname_for_mech(OID mech not None): | ||
""" | ||
inquire_saslname_for_mech(mech) | ||
Gets information about a specified mech, including the SASL name, | ||
the mech name, and the mech description. | ||
|
||
Args: | ||
mech (OID): Mechanism to inquire about | ||
|
||
Returns: | ||
InquireSASLNameResult: the results of inquiry; a mech's SASL name, | ||
name, and description. | ||
|
||
Raises: | ||
GSSError: an unknown failure occurred | ||
""" | ||
cdef OM_uint32 maj_stat, min_stat | ||
cdef gss_buffer_desc sasl_mech_name | ||
cdef gss_buffer_desc mech_name | ||
cdef gss_buffer_desc mech_desc | ||
cdef gss_OID m = GSS_C_NO_OID | ||
|
||
m = &mech.raw_oid | ||
|
||
with nogil: | ||
maj_stat = gss_inquire_saslname_for_mech(&min_stat, m, &sasl_mech_name, | ||
&mech_name, &mech_desc) | ||
|
||
if maj_stat == GSS_S_COMPLETE: | ||
out_smn = sasl_mech_name.value[:sasl_mech_name.length] | ||
out_mn = mech_name.value[:mech_name.length] | ||
out_md = mech_desc.value[:mech_desc.length] | ||
|
||
gss_release_buffer(&min_stat, &sasl_mech_name) | ||
gss_release_buffer(&min_stat, &mech_name) | ||
gss_release_buffer(&min_stat, &mech_desc) | ||
|
||
return InquireSASLNameResult(out_smn, out_mn, out_md) | ||
else: | ||
raise GSSError(maj_stat, min_stat) | ||
|
||
|
||
def inquire_mech_for_saslname(bytes sasl_name not None): | ||
""" | ||
inquire_mech_for_saslname(sasl_name) | ||
Gets the OID for the mech specified by SASL name. | ||
|
||
Args: | ||
sasl_name (bytes): SASL name of the mechanism | ||
|
||
Returns: | ||
OID: the mechanism with corresponding SASL name. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing a |
||
|
||
Raises: | ||
GSSError: An unknown failure occurred | ||
""" | ||
cdef OM_uint32 maj_stat, min_stat | ||
cdef gss_buffer_desc sn | ||
cdef gss_OID m | ||
|
||
sn.length = len(sasl_name) | ||
sn.value = sasl_name | ||
|
||
with nogil: | ||
maj_stat = gss_inquire_mech_for_saslname(&min_stat, &sn, &m) | ||
|
||
if maj_stat == GSS_S_COMPLETE: | ||
return c_make_oid(m) | ||
else: | ||
raise GSSError(maj_stat, min_stat) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a
Raises
clause.