Giter Club home page Giter Club logo

Comments (4)

lambdaTotoro avatar lambdaTotoro commented on June 19, 2024

I've been looking into this for #79 and from the looks of it and the documentation says so, too.
There's an example on how to automatically give the correct path here, could you try that and see if it works for you?

from nativeauthenticator.

JohnPaton avatar JohnPaton commented on June 19, 2024

I'm not running this anymore so I don't have a setup to try it out on, sorry. But at a glance it doesn't look like the same issue, the question was about how to extend the provided templates as a user.

from nativeauthenticator.

lambdaTotoro avatar lambdaTotoro commented on June 19, 2024

That's true, but if you add the nativeauthenticator template directory to the configuration file as instructed over there you should be able to easily extend the templates as you do here.

But since you don't actually run this any more, I'll close this issue.

from nativeauthenticator.

unkcpz avatar unkcpz commented on June 19, 2024

Just came across this issue and this is how we override the template, it requires a trick to modify the login handler since nativeauthenticator change it to native-login.html instead of the default login.html. Here is my jupyterhub config (https://github.com/aiidalab/aiidalab-microk8s-deploy/blob/0702fe11c22f85f3bb3094ddf1c44cb2c5aeb207/basehub/values.yaml#L77-L125):

jupyterhub:
    ... (other settings)
    hub:
        db:
            pvc:
                storageClassName: nfs-client
        extraConfig:
            00-logo: |
                c.JupyterHub.logo_file = "/usr/local/share/jupyterhub/static/external/aiidalab-wide-logo.png"
            01-auth: |
                from tornado.escape import url_escape
                from tornado.httputil import url_concat
                from nativeauthenticator import NativeAuthenticator
                from nativeauthenticator import handlers

                class CustomizeLoginHandler(handlers.LoginHandler):

                    def _render(self, login_error=None, username=None):
                        """For 'normal' rendering."""

                        return self.render_template(
                            "customize-native-login.html",
                            next=url_escape(self.get_argument("next", default="")),
                            username=username,
                            login_error=login_error,
                            custom_html=self.authenticator.custom_html,
                            login_url=self.settings["login_url"],
                            enable_signup=self.authenticator.enable_signup,
                            two_factor_auth=self.authenticator.allow_2fa,
                            authenticator_login_url=url_concat(
                                self.authenticator.login_url(self.hub.base_url),
                                {"next": self.get_argument("next", "")},
                            ),
                        )

                class CustomNativeAuthenticator(NativeAuthenticator):
                    def __init__(self, *args, **kwargs):
                        super().__init__(*args, **kwargs)
                        self.minimum_password_length = 8
                        self.check_common_password = True
                        self.ask_email_on_signup = True

                    def get_handlers(self, app):
                        native_handlers = [
                            (r"/login", CustomizeLoginHandler),
                            (r"/signup", handlers.SignUpHandler),
                            (r"/discard/([^/]*)", handlers.DiscardHandler),
                            (r"/authorize", handlers.AuthorizationAreaHandler),
                            (r"/authorize/([^/]*)", handlers.ToggleAuthorizationHandler),
                            # the following /confirm/ must be like in generate_approval_url()
                            (r"/confirm/([^/]*)", handlers.EmailAuthorizationHandler),
                            (r"/change-password", handlers.ChangePasswordHandler),
                            (r"/change-password/([^/]+)", handlers.ChangePasswordAdminHandler),
                        ]
                        return native_handlers

                c.Authenticator.admin_users = {'admin'}
                c.JupyterHub.authenticator_class = CustomNativeAuthenticator

and I have customize-native-login.html in the template path as modifing login.html as mentioned in the documentation

{% extends "native-login.html" %}

{% block title %}PSI AiiDAlab - Login{% endblock %}

....

from nativeauthenticator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.