Skip to content
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

Issue 1655: Add authorize credentials list and removal on organization under SAML #1676

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

AlexandreODelisle
Copy link

@AlexandreODelisle AlexandreODelisle commented Aug 27, 2020

The objective is to implement the two available methods to list and remove credential ids linked to an Organization that have been Authorize by the user to act as authentication on the Organization.

Added the two endpoints available under the Organization on the GitHub API
https://developer.github.com/v3/orgs/#list-saml-sso-authorizations-for-an-organization
https://developer.github.com/v3/orgs/#remove-a-saml-sso-authorization-for-an-organization

Also needed to create a new Object to handle the return payload of the API since the raw data differs from the Authorization Object..

Added one unit test to list the credentials under an Organization, but I do not have a Organization that is SAML protected that I can use to display in the unittest.. So I added on a personnal organization with no SAML, so an empty List is validated.

#1655

Copy link
Collaborator

@s-t-e-v-e-n-k s-t-e-v-e-n-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good start, but requires more before merging. Thanks!

@property
def token_last_eight(self) -> str: ...
@property
def scopes(self) -> list: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List[] including the types, such as List[str], please.

from . import Framework


class Organization1655(Framework.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a better name, such as OrganizationAuthorization?


def testGetCredentialsAuth(self):
credentials_list = self.org.get_credential_authorizations()
self.assertListEqual(credentials_list, [])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to test delete, but I'd also prefer we return something so we can verify the returned attributes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to wait in that case, since the only Organization I have available at the moment,with SAML SSO, is private. I can not display the credentials list in the --record. I will ask GitHub sales for a trial for Entreprise Org hosted on GitHub.


############################ Copyrights and license ############################
# #
# Copyright 2020 Alexandre Delisle <alexodelisle @gmail.com> #
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space in the email address.

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2020

Codecov Report

Merging #1676 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1676      +/-   ##
==========================================
+ Coverage   98.67%   98.69%   +0.02%     
==========================================
  Files          48       49       +1     
  Lines        2561     2609      +48     
==========================================
+ Hits         2527     2575      +48     
  Misses         34       34              
Impacted Files Coverage Δ
github/AuthorizationOrganization.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ec4f15...a699832. Read the comment docs.

@AlexandreODelisle
Copy link
Author

@s-t-e-v-e-n-k , finally got the coverage to pass. I think I got all the reviews, since there is now test for the Attributes and repr, also got an Enterprise Team so the credential list also has non redacted information.
Thanks

Copy link
Collaborator

@s-t-e-v-e-n-k s-t-e-v-e-n-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking like a great start, I have some concerns.

def get_credential_authorizations(self):
"""
:calls: `GET /orgs/:org/credential-authorizations <https://developer.github.com/v3/orgs>`_
:rtype: list
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list of :class:github.AuthorizationOrganization.AuthorizationOrganization_

(I'm not certain of the formatting, but roughly that, please)

def remove_credential_authorization(
self,
credential_id: Union[int, _NotSetType] = ...,
) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type is not None.


class AuthorizationOrganization(github.GithubObject.NonCompletableGithubObject):
"""
This class represents a credential id.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like more detail here, along with a link to the documentation of the object.

@stale
Copy link

stale bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 8, 2022
@alexef
Copy link

alexef commented Mar 14, 2022

Any chance this gets some traction?

@stale stale bot removed the stale label Mar 14, 2022
@EnricoMi
Copy link
Collaborator

@AlexandreODelisle this is awesome, can we get this over the finish line? Happy to approve once review comments are resolved.

@alambike
Copy link

alambike commented Sep 8, 2023

Is it possible to do something with this to resume this pull request and be able to have this functionality in PyGithub? Is it correct to create a new PR with these changes to be able to work on it? cc/ @EnricoMi , @AlexandreODelisle

@AlexandreODelisle
Copy link
Author

Please feel free to go ahead with it.

Personally, I am no longer using SAML SSO on a regular basis for authentication, and also another py package.

I am sorry for the delay in response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants