-
Notifications
You must be signed in to change notification settings - Fork 66
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
Refactor oidc-authservice
by adding 4 new packages
#105
Merged
Conversation
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
athamark
pushed a commit
that referenced
this pull request
Jan 5, 2023
Introduced a new common package which includes commonly used variables, functions and constants across our code. This package also includes the respective unit tests. Also factored out the definition of a Cacheable authenticator. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]>
athamark
pushed a commit
that referenced
this pull request
Jan 5, 2023
Cleaned up direct deps on go-oidc. Established a clear interface for for what we require from go-oidc and isolated that inside the oidc package. This enables us to consolidate our OIDC related operations in a single place as well as reducing irritating collisions between go-oidc and the internal oidc package. GitHub-PR: #105 Signed-off-by: Mike Kelly <[email protected]> Signed-off-by: Athanasios Markou <[email protected]>
athamark
pushed a commit
that referenced
this pull request
Jan 5, 2023
Isolated the coreos/go-oidc dependencies within our new sessions package. Under the sessions package we have all the session related functions and variables. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]>
athamark
pushed a commit
that referenced
this pull request
Jan 5, 2023
Add a new authenticators package which includes the implementations of all the authentication methods that oidc-authservice currently supports. Isolate the dependency to the "k8s.io/apiserver/pkg/authentication/authenticator" package, inside the new authenticators package. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]>
athamark
force-pushed
the
feature-athamark-pkg-refactoring
branch
from
January 5, 2023 13:05
541bac2
to
0e63d97
Compare
athamark
pushed a commit
that referenced
this pull request
Feb 3, 2023
Introduced a new common package which includes commonly used variables, functions and constants across our code. This package also includes the respective unit tests. Also factored out the definition of a Cacheable authenticator. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]>
athamark
pushed a commit
that referenced
this pull request
Feb 3, 2023
Cleaned up direct deps on go-oidc. Established a clear interface for for what we require from go-oidc and isolated that inside the oidc package. This enables us to consolidate our OIDC related operations in a single place as well as reducing irritating collisions between go-oidc and the internal oidc package. GitHub-PR: #105 Signed-off-by: Mike Kelly <[email protected]> Signed-off-by: Athanasios Markou <[email protected]>
athamark
pushed a commit
that referenced
this pull request
Feb 3, 2023
Isolated the coreos/go-oidc dependencies within our new sessions package. Under the sessions package we have all the session related functions and variables. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]>
athamark
pushed a commit
that referenced
this pull request
Feb 3, 2023
Add a new authenticators package which includes the implementations of all the authentication methods that oidc-authservice currently supports. Isolate the dependency to the "k8s.io/apiserver/pkg/authentication/authenticator" package, inside the new authenticators package. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]>
athamark
force-pushed
the
feature-athamark-pkg-refactoring
branch
from
February 3, 2023 13:53
0e63d97
to
3f80ac1
Compare
elikatsis
pushed a commit
that referenced
this pull request
Feb 7, 2023
Introduce a new 'common' package which includes commonly used variables, functions and constants across our code. This package also includes the respective unit tests. Also factor out the definition of a Cacheable authenticator. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
elikatsis
pushed a commit
that referenced
this pull request
Feb 7, 2023
Clean up direct imports of 'go-oidc'. Establish a clear interface for for what we require from 'go-oidc' and isolate it inside the 'oidc' package. This enables to consolidate the OIDC related operations in a single place as well as to reduce irritating collisions between 'go-oidc' and the internal 'oidc' package. GitHub-PR: #105 Signed-off-by: Mike Kelly <[email protected]> Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
elikatsis
pushed a commit
that referenced
this pull request
Feb 7, 2023
Isolate the 'gorilla/sessions' dependencies within our new 'sessions' package. Under the 'sessions' package we have all the session related functions and variables. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
elikatsis
pushed a commit
that referenced
this pull request
Feb 7, 2023
Add a new authenticators package which includes the implementations of all the authentication methods that oidc-authservice currently supports. Isolate the dependency to the "k8s.io/apiserver/pkg/authentication/authenticator" package, inside the new authenticators package. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
Introduce a new 'common' package which includes commonly used variables, functions and constants across our code. This package also includes the respective unit tests. Also factor out the definition of a Cacheable authenticator. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
elikatsis
pushed a commit
that referenced
this pull request
Feb 7, 2023
Clean up direct imports of 'go-oidc'. Establish a clear interface for for what we require from 'go-oidc' and isolate it inside the 'oidc' package. This enables to consolidate the OIDC related operations in a single place as well as to reduce irritating collisions between 'go-oidc' and the internal 'oidc' package. GitHub-PR: #105 Signed-off-by: Mike Kelly <[email protected]> Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
elikatsis
pushed a commit
that referenced
this pull request
Feb 7, 2023
Isolate the 'gorilla/sessions' dependencies within our new 'sessions' package. Under the 'sessions' package we have all the session related functions and variables. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
elikatsis
pushed a commit
that referenced
this pull request
Feb 7, 2023
Add a new authenticators package which includes the implementations of all the authentication methods that oidc-authservice currently supports. Isolate the dependency to the "k8s.io/apiserver/pkg/authentication/authenticator" package, inside the new authenticators package. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
Clean up direct imports of 'go-oidc'. Establish a clear interface for for what we require from 'go-oidc' and isolate it inside the 'oidc' package. This enables to consolidate the OIDC related operations in a single place as well as to reduce irritating collisions between 'go-oidc' and the internal 'oidc' package. GitHub-PR: #105 Signed-off-by: Mike Kelly <[email protected]> Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
Isolate the 'gorilla/sessions' dependencies within our new 'sessions' package. Under the 'sessions' package we have all the session related functions and variables. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
Add a new authenticators package which includes the implementations of all the authentication methods that oidc-authservice currently supports. Isolate the dependency to the "k8s.io/apiserver/pkg/authentication/authenticator" package, inside the new authenticators package. GitHub-PR: #105 Signed-off-by: Athanasios Markou <[email protected]> Reviewed-by: Ilias Katsakioris <[email protected]>
elikatsis
force-pushed
the
feature-athamark-pkg-refactoring
branch
from
February 7, 2023 14:24
3f80ac1
to
ce07332
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Goal
In this PR, we refactor our
oidc-authservice
codebase. There are two upstream PRs that correlate with this effort:coreos/go-oidc
) so that they are called only within the respective packages. This is a good approach, one problem with simply proceeding with reviewing this PR is that it is outdated (over 1 year) and there are many changes which are not included. Moreover, we want a different package structure than the one proposed in the PR. We did however cherry-pick one commit that complied with our target.pkg/common
.We examined these two efforts and concluded to a solution that hopefully combines the best aspects of both. Undoubtedly, we deviated from the above approaches wherever necessary.
Useful Material
Here is a codebase refactoring in Golang article that provides the necessary pronciples that we need to considerate when refactoring our code: https://go.dev/talks/2016/refactor.article. One important thing that we need to keep in mind is that the package structure we will implement needs to avoid any circular dependencies.
The functions, variables, structs, struct fields, interfaces and constant values names that we want to export from every one of the new packages, need to start with a capital otherwise they will not be accessible/visible to the caller. Source: https://go.dev/tour/basics/3
Proposed Implementation
The goal is to introduce 4 new packages:
common
oidc
sessions
authenticators
We need to introduce these packages in the order described above.
Local package dependencies
main
package will importauthenticators
,session
,oidc
andcommon
authenticators
package will importsessions
,oidc
andcommon
sessions
package will importoidc
andcommon
oidc
package will importcommon
To ensure that no circular dependency gets introduced we will have to transfer some functions to different files.
File structure
Here is what each directory package will include, in parenthesis I expose the old filename:
Note to the reviewer
Since the #103 PR is not yet merged, we worked on top of it.