Skip to content

Export SSO types and functions in lib/web#17530

Merged
camscale merged 5 commits intomasterfrom
camh/export-sso
Oct 19, 2022
Merged

Export SSO types and functions in lib/web#17530
camscale merged 5 commits intomasterfrom
camh/export-sso

Conversation

@camscale
Copy link
Copy Markdown
Contributor

@camscale camscale commented Oct 18, 2022

Export some names in the lib/web package so that SSO auth plugins can be implemented from outside this package:

  • struct ssoRequestParams (including fields)
  • struct ssoCallbackResponse (including fields)
  • func parseSSORequestParams
  • func ssoSetWebSessionAndRedirectURL
  • func redirectURLWithError
  • var ssoLoginConsoleErr
  • type CachedSessionLingeringThreshold (for TestSAML)

Issue: https://github.com/gravitational/teleport.e/issues/525


Note: This supersedes PR #17457, exporting much less while still enabling the SAML lib/web tests to
move to the enterprise repo.

Follow-on PRs are:

Export some names in the `lib/auth` package so that SSO auth plugins can
be implemented from outside this package:

  * struct `ssoRequestParams` (including fields)
  * struct `ssoCallbackResponse` (including fields)
  * func `parseSSORequestParams`
  * func `ssoSetWebSessionAndRedirectURL`
  * func `redirectURLWithError`
  * var `ssoLoginConsoleErr`
  * type `CachedSessionLingeringThreshold` (for TestSAML)
@github-actions github-actions Bot requested review from LKozlowski and r0mant October 18, 2022 04:20
@camscale
Copy link
Copy Markdown
Contributor Author

This PR supersedes #17457, taking a cut-down approach to what is exported.

Copy link
Copy Markdown
Contributor

@Tener Tener left a comment

Choose a reason for hiding this comment

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

Looks good, the only issue I can see is some missing docs.

Comment thread lib/web/apiserver.go
}

func redirectURLWithError(clientRedirectURL string, errReply error) (*url.URL, error) {
func RedirectURLWithError(clientRedirectURL string, errReply error) (*url.URL, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing doc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread lib/web/apiserver.go
clientRedirectURL string
connectorID string
csrfToken string
type SSORequestParams struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing doc for type and fields.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread lib/web/apiserver.go
}

func parseSSORequestParams(r *http.Request) (*ssoRequestParams, error) {
func ParseSSORequestParams(r *http.Request) (*SSORequestParams, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing doc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread lib/web/apiserver.go
username string
sessionName string
clientRedirectURL string
type SSOCallbackResponse struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing doc for type and fields.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread lib/web/apiserver.go
}

func ssoSetWebSessionAndRedirectURL(w http.ResponseWriter, r *http.Request, response *ssoCallbackResponse, verifyCSRF bool) error {
func SSOSetWebSessionAndRedirectURL(w http.ResponseWriter, r *http.Request, response *SSOCallbackResponse, verifyCSRF bool) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing doc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread lib/web/apiserver.go Outdated
const (
// ssoLoginConsoleErr is a generic error message to hide revealing sso login failure msgs.
ssoLoginConsoleErr = "Failed to login. Please check Teleport's log for more details."
// SSOLoginConsoleErr is a generic error message to hide revealing sso login failure msgs.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// SSOLoginConsoleErr is a generic error message to hide revealing sso login failure msgs.
// SSOLoginConsoleErr is a generic error message avoid disclosing sensitive SSO failure messages.

When something is exported, it's extra important to get the name and documentation right.

Additionally, I would generally expect that something named FooErr implements error, and this is just a string. Maybe SSOLoginFailureMessage or something along those lines would be a better name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ack. renamed and updated doc string as suggested.

Rename SSOLoginConsoleErr to SSOLoginFailureMessage and update the doc
string to be grammatically correct.

Addresses: #17530 (comment)
@camscale camscale enabled auto-merge (squash) October 18, 2022 23:55
@camscale camscale merged commit 78cfbfd into master Oct 19, 2022
@camscale camscale deleted the camh/export-sso branch October 19, 2022 03:33
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.

4 participants