middleware icon indicating copy to clipboard operation
middleware copied to clipboard

NAS-127183 / 24.10 / Customer designated login banner

Open aiden3c opened this issue 1 year ago • 14 comments

Government systems require a login banner prior to being allowed to log in. In the ticket it was determined to reuse the motd as our banner. This PR has the middleware portion of this ticket. On top of giving a public endpoint for motd, we also have our motd_before_login option, which updates our sshd configuration to show our MOTD prior to login. Our database string length has also been upped from 1024 to 4096 (DoD requires 1300 minimum to fit the bare minimum message).

aiden3c avatar Jun 17 '24 18:06 aiden3c

Jira URL: https://ixsystems.atlassian.net/browse/NAS-127183

bugclerk avatar Jun 17 '24 18:06 bugclerk

Is there any reason to not just always display motd before login?

anodos325 avatar Jun 17 '24 18:06 anodos325

Is there any reason to not just always display motd before login?

On the WebUI it could get annoying to have a popup modal every single time you log in with the motd. For the SSH part, we could do that but might as well keep parity with the WebUI for that logic.

aiden3c avatar Jun 17 '24 18:06 aiden3c

Instead of parsing the SSH session, would verifying that the SSHd config contains the banner line be sufficient? As well as looking to see that the contents of /etc/motd is also what we just set.

aiden3c avatar Jun 18 '24 14:06 aiden3c

Have a passing test!

aiden3c avatar Jun 21 '24 13:06 aiden3c

~~Still have to go through and redo the DB migration so its revision hashes are correct~~

Doesn't look like any alembic changes were made actually, I was under the impression that this PR had DB changes.

Should be clear to just merge as is.

aiden3c avatar Jun 21 '24 13:06 aiden3c

I added the checkbox as it was suggested in the ticket! The reasoning (from what I assume) is to prevent having a popup every single time you log in (although we could just have it show up on the login page in general, not as a modal, but then there's UI flow issues with large banners). This is also to not suddenly start showing the MOTD for every user with it set (which would be just about everyone since we have a default "Welcome to TrueNAS").

aiden3c avatar Jun 21 '24 13:06 aiden3c

I also updated my migration references to point to our most recent migration from the last 24 hrs

aiden3c avatar Jun 28 '24 12:06 aiden3c

@anodos325 how would we go about deleting the old /etc/login_banner if it's in its own mako? If exiting early stops the file from being written, then I could probably do a delete then exit early.

aiden3c avatar Jun 28 '24 13:06 aiden3c

@anodos325 how would we go about deleting the old /etc/login_banner if it's in its own mako? If exiting early stops the file from being written, then I could probably do a delete then exit early.

raise FileShouldNotExist within mako file (you will need to import from etc plugin)

anodos325 avatar Jun 28 '24 13:06 anodos325

@anodos325 I've implemented those changes! Is there any way to specify that when we're reloading the ssh service that we should etc generate our login_banner as well? Would save us a line in the config.py

aiden3c avatar Jun 28 '24 13:06 aiden3c

Login banner needs to be a separate etc file with entry in etc plugin defining permissions required. no_auth_required + roles still needs to be resolved.

I'm looking into this right now

aiden3c avatar Jun 28 '24 13:06 aiden3c

@anodos325 I've implemented those changes! Is there any way to specify that when we're reloading the ssh service that we should etc generate our login_banner as well? Would save us a line in the config.py

If you put the login banner in the etc group for ssh then it will be generated every time etc.generate ssh is called.

anodos325 avatar Jun 28 '24 14:06 anodos325

The no_authz_required issue was me putting the accepts decorator above the no_authz_required, moving it below fixes it.

Should be good for final review now!

aiden3c avatar Jun 28 '24 14:06 aiden3c

This PR has been merged and conversations have been locked. If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

bugclerk avatar Jul 03 '24 12:07 bugclerk