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

feat(web): custom reset password link #2854

Closed
wants to merge 3 commits into from
Closed

feat(web): custom reset password link #2854

wants to merge 3 commits into from

Conversation

you1996
Copy link
Contributor

@you1996 you1996 commented Feb 7, 2022

feat(authentication): custom reset password URL

Administrators can now redirect users to their custom password reset portal and configure authelia to do so by disabling the internal password reset procedure and enabling the option to use an external portal in the case of some businesses who employ one.

Fixes #1934.

@authelia
Copy link

authelia bot commented Feb 7, 2022

Thanks for choosing to contribute @you1996. We lint all PR's with golangci-lint and eslint, I may add a review to your PR with some suggestions.

You are free to apply the changes if you're comfortable, alternatively you are welcome to ask a team member for advice.

Artifacts

These changes once approved by a team member will be published for testing on Buildkite, DockerHub and GitHub Container Registry.

Docker Container

  • docker pull authelia/authelia:PR2854
  • docker pull ghcr.io/authelia/authelia:PR2854

Copy link
Member

@james-d-elliott james-d-elliott left a comment

Choose a reason for hiding this comment

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

So all looks fine to me. Just one suggestion around simplifying the configuration and something that will allow us to group other related options. I'll merge master into this branch and provide an example of how to utilize a URL struct in the config.

Edit: Seems I don't have permission to merge master into this. Please do so and you'll be able to use url.URL as in the configuration struct.

config.template.yml Show resolved Hide resolved
docs/configuration/authentication/index.md Show resolved Hide resolved
docs/configuration/authentication/index.md Show resolved Hide resolved
internal/configuration/config.template.yml Show resolved Hide resolved
internal/server/template.go Show resolved Hide resolved
web/index.html Show resolved Hide resolved
web/.env.production Show resolved Hide resolved
web/.env.development Show resolved Hide resolved
web/src/utils/Configuration.ts Show resolved Hide resolved
@james-d-elliott james-d-elliott changed the title feat(authentication): custom reset password link feat(web): custom reset password link Mar 16, 2022
@@ -33,6 +33,17 @@
validator.Push(fmt.Errorf(errFmtAuthBackendRefreshInterval, config.RefreshInterval, err))
}
}

if configuration.EnableExternalResetPassword && !configuration.DisableResetPassword {
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undeclared name: configuration (typecheck)

@@ -33,6 +33,17 @@
validator.Push(fmt.Errorf(errFmtAuthBackendRefreshInterval, config.RefreshInterval, err))
}
}

if configuration.EnableExternalResetPassword && !configuration.DisableResetPassword {
validator.Push(errors.New("You cannot enable both `internal reset password` and `external reset password` processes in `authentication_backend`"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undeclared name: errors (typecheck)

validator.Push(errors.New("You cannot enable both `internal reset password` and `external reset password` processes in `authentication_backend`"))
}

if configuration.EnableExternalResetPassword {
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undeclared name: configuration (typecheck)

}

if configuration.EnableExternalResetPassword {
err := utils.IsStringAbsURL(configuration.ExternalResetPasswordURL)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
undeclared name: configuration (typecheck)

@@ -230,6 +230,19 @@
suite.Assert().False(suite.validator.HasErrors())
}

func (suite *FileBasedAuthenticationBackend) TestShouldRaiseErrorWhenResetURLIsInvalid() {
suite.configuration.EnableExternalResetPassword = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
suite.configuration undefined (type *FileBasedAuthenticationBackend has no field or method configuration) (typecheck)

@@ -230,6 +230,19 @@
suite.Assert().False(suite.validator.HasErrors())
}

func (suite *FileBasedAuthenticationBackend) TestShouldRaiseErrorWhenResetURLIsInvalid() {
suite.configuration.EnableExternalResetPassword = true
suite.configuration.DisableResetPassword = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
suite.configuration undefined (type *FileBasedAuthenticationBackend has no field or method configuration) (typecheck)

func (suite *FileBasedAuthenticationBackend) TestShouldRaiseErrorWhenResetURLIsInvalid() {
suite.configuration.EnableExternalResetPassword = true
suite.configuration.DisableResetPassword = true
suite.configuration.ExternalResetPasswordURL = "example.com" //nolint:goconst
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
suite.configuration undefined (type *FileBasedAuthenticationBackend has no field or method configuration) (typecheck)

suite.configuration.DisableResetPassword = true
suite.configuration.ExternalResetPasswordURL = "example.com" //nolint:goconst

ValidateAuthenticationBackend(&suite.configuration, suite.validator)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
suite.configuration undefined (type *FileBasedAuthenticationBackend has no field or method configuration) (typecheck)

@you1996
Copy link
Contributor Author

you1996 commented Mar 16, 2022

So all looks fine to me. Just one suggestion around simplifying the configuration and something that will allow us to group other related options. I'll merge master into this branch and provide an example of how to utilize a URL struct in the config.

Edit: Seems I don't have permission to merge master into this. Please do so and you'll be able to use url.URL as in the configuration struct.

Hello james, thank you for the review, merge done.

@james-d-elliott
Copy link
Member

So all looks fine to me. Just one suggestion around simplifying the configuration and something that will allow us to group other related options. I'll merge master into this branch and provide an example of how to utilize a URL struct in the config.
Edit: Seems I don't have permission to merge master into this. Please do so and you'll be able to use url.URL as in the configuration struct.

Hello james, thank you for the review, merge done.

Nice one! You'll have to change the references in the validator from configuration to config. We shortened it since the additional uration was superfluous.

@james-d-elliott james-d-elliott added the status/needs-review Pull requests that need to be reviewed label Mar 30, 2022
@james-d-elliott
Copy link
Member

Did you get around to those fixes? Once I merge all the other 4.35.0 images I am hoping this is ready or I'll have to fix it up myself.

I'd appreciate if I can push to this branch if you don't have time to fix this up, though I can manually takeover this PR worst case scenario, you can enable this by clicking this checkbox:

image

@james-d-elliott james-d-elliott removed the status/needs-review Pull requests that need to be reviewed label Mar 30, 2022
james-d-elliott added a commit that referenced this pull request Apr 4, 2022
This allows providing a custom URL for password resets. If provided the disable_reset_password option is ignored, the password reset API is disabled, and the button provided in the UI to reset the password redirects users to the configured endpoint.

Closes #1934, Closes #2854

Co-authored-by: you1996 <youssri@flyweight.tech>
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.

Customize Reset Password URL
3 participants