3232
3333
3434class BlueskyCredentialsAdminForm (forms .ModelForm ):
35- """Admin form that accepts a plaintext app password without exposing ciphertext ."""
35+ """Admin form that accepts a plaintext Bluesky app credential input ."""
3636
37- app_password = forms .CharField (
37+ credential_input = forms .CharField (
3838 required = False ,
3939 strip = False ,
4040 widget = forms .PasswordInput (render_value = False ),
41- help_text = (
42- "Leave blank to keep the existing app password. Stored encrypted at rest."
43- ),
44- label = "App password" ,
41+ help_text = "Leave blank to keep the existing stored credential." ,
42+ label = "Bluesky app credential" ,
4543 )
4644
4745 class Meta :
4846 model = BlueskyCredentials
49- fields = ["project" , "handle" , "app_password" , " pds_url" , "is_active" ]
47+ fields = ["project" , "handle" , "pds_url" , "is_active" ]
5048
5149 def clean (self ):
52- """Require an app password when creating credentials for the first time."""
50+ """Require a credential when creating the record for the first time."""
5351
5452 cleaned_data = super ().clean ()
55- app_password = cleaned_data .get ("app_password " , "" )
56- if not self .instance .has_app_password () and not app_password :
57- self .add_error ("app_password " , "App password is required." )
53+ credential_input = cleaned_data .get ("credential_input " , "" )
54+ if not self .instance .has_stored_credential () and not credential_input :
55+ self .add_error ("credential_input " , "A Bluesky app credential is required." )
5856 return cleaned_data
5957
6058 def save (self , commit = True ):
61- """Encrypt a new app password before saving the model instance."""
59+ """Encrypt a new credential value before saving the model instance."""
6260
6361 instance = super ().save (commit = False )
64- app_password = self .cleaned_data .get ("app_password " , "" )
65- if app_password :
66- instance .set_app_password ( app_password )
62+ credential_input = self .cleaned_data .get ("credential_input " , "" )
63+ if credential_input :
64+ instance .set_stored_credential ( credential_input )
6765 if commit :
6866 instance .save ()
6967 return instance
@@ -99,15 +97,15 @@ class BlueskyCredentialsAdmin(ModelAdmin):
9997 "project" ,
10098 "handle" ,
10199 "display_pds_host" ,
102- "has_stored_app_password " ,
100+ "has_stored_credential " ,
103101 "is_active" ,
104102 "last_verified_at" ,
105103 )
106104 list_filter = ("is_active" , ("project" , admin .RelatedOnlyFieldListFilter ))
107105 search_fields = ("project__name" , "handle" , "pds_url" )
108106 autocomplete_fields = ("project" ,)
109107 readonly_fields = (
110- "has_stored_app_password " ,
108+ "has_stored_credential " ,
111109 "last_verified_at" ,
112110 "last_error" ,
113111 "created_at" ,
@@ -116,7 +114,7 @@ class BlueskyCredentialsAdmin(ModelAdmin):
116114 fieldsets = (
117115 (
118116 "Account" ,
119- {"fields" : ("project" , "handle" , "app_password " , "is_active" )},
117+ {"fields" : ("project" , "handle" , "credential_input " , "is_active" )},
120118 ),
121119 (
122120 "PDS Override" ,
@@ -129,7 +127,7 @@ class BlueskyCredentialsAdmin(ModelAdmin):
129127 "Verification" ,
130128 {
131129 "fields" : (
132- "has_stored_app_password " ,
130+ "has_stored_credential " ,
133131 "last_verified_at" ,
134132 "last_error" ,
135133 "created_at" ,
@@ -145,11 +143,11 @@ def display_pds_host(self, obj):
145143
146144 return obj .pds_url or "Bluesky hosted default"
147145
148- @admin .display (boolean = True , description = "Stored App Password " )
149- def has_stored_app_password (self , obj ):
150- """Return whether an encrypted app password has been configured."""
146+ @admin .display (boolean = True , description = "Stored Credential " )
147+ def has_stored_credential (self , obj ):
148+ """Return whether an encrypted Bluesky credential has been configured."""
151149
152- return obj .has_app_password ()
150+ return obj .has_stored_credential ()
153151
154152 @admin .action (description = "Verify Selected Credentials" )
155153 def verify_selected_credentials (self , request , queryset ):
0 commit comments