-
Notifications
You must be signed in to change notification settings - Fork 499
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
NAS-127183 / 24.10 / Customer designated login banner #13892
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
65fb7fd
Added login_banner
aiden3c 164ed65
Merge remote-tracking branch 'origin/master' into NAS-127183
aiden3c 8719d63
Changed to use login_banner instead of reusing motd
aiden3c 78fa6cd
Change double to single quote
aiden3c e9dfba7
Added test
aiden3c ac57c1c
Merge remote-tracking branch 'origin/master' into NAS-127183
aiden3c 8221d75
Fixed migration, also added requested changes
aiden3c 32fcb89
Suggested changes
aiden3c 2a0944d
Moved login_banner to own mako
aiden3c 60463ba
Reworked etc entry and perms
aiden3c 0fcfb43
login_banner ctx persistence, also updated test to use WS
aiden3c e8382e7
Updated tests
aiden3c 742bb28
Fixed tests
aiden3c 128b1a6
Undo changes to old test, added new test
aiden3c 21a8cb9
Removed redundant imports
aiden3c File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/middlewared/middlewared/alembic/versions/24.10/2024-06-28_07-35_add_login_banner.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Add login_banner column | ||
|
||
Revision ID: 1307a8e6a8b6 | ||
Revises: d8bfbf4e277e | ||
Create Date: 2024-06-24 12:57:36.048308+00:00 | ||
|
||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '1307a8e6a8b6' | ||
down_revision = 'd8bfbf4e277e' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('system_advanced', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('adv_login_banner', sa.Text(), nullable=False, server_default='')) | ||
|
||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('system_advanced', schema=None) as batch_op: | ||
batch_op.drop_column('adv_login_banner') |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<% | ||
login_banner = render_ctx['system.advanced.login_banner'] | ||
if login_banner == '': | ||
raise FileShouldNotExist() | ||
%>\ | ||
${login_banner} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from middlewared.test.integration.utils import call, ssh | ||
|
||
def test_system_advanced_login_banner(): | ||
results = call('system.advanced.update', { | ||
'login_banner': 'TrueNAS login banner.' | ||
}) | ||
results = call('system.advanced.config') | ||
assert results['login_banner'] == 'TrueNAS login banner.' | ||
results = ssh('grep Banner /etc/ssh/sshd_config', complete_response=True) | ||
assert results['result'] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to add
system.advanced.login_banner
toctx
above so that we only query once and provide to all scripts in this group.