sources/oauth: save null instead of empty string for sources without configurable URLs

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-04-17 21:13:33 +02:00
parent a0cd17a257
commit 52abd959eb
9 changed files with 176 additions and 74 deletions

View File

@ -68,7 +68,7 @@ msgstr "API request failed"
msgid "Access Key"
msgstr "Access Key"
#: src/pages/sources/oauth/OAuthSourceForm.ts:72
#: src/pages/sources/oauth/OAuthSourceForm.ts:73
msgid "Access token URL"
msgstr "Access token URL"
@ -274,7 +274,7 @@ msgstr "Audience"
msgid "Authentication"
msgstr "Authentication"
#: src/pages/sources/oauth/OAuthSourceForm.ts:175
#: src/pages/sources/oauth/OAuthSourceForm.ts:189
#: src/pages/sources/saml/SAMLSourceForm.ts:245
msgid "Authentication flow"
msgstr "Authentication flow"
@ -292,7 +292,7 @@ msgstr "Authorization"
msgid "Authorization Code"
msgstr "Authorization Code"
#: src/pages/sources/oauth/OAuthSourceForm.ts:65
#: src/pages/sources/oauth/OAuthSourceForm.ts:66
#: src/pages/sources/oauth/OAuthSourceViewPage.ts:95
msgid "Authorization URL"
msgstr "Authorization URL"
@ -649,11 +649,11 @@ msgstr "Consider Objects matching this filter to be Groups."
msgid "Consider Objects matching this filter to be Users."
msgstr "Consider Objects matching this filter to be Users."
#: src/pages/sources/oauth/OAuthSourceForm.ts:124
#: src/pages/sources/oauth/OAuthSourceForm.ts:126
msgid "Consumer key"
msgstr "Consumer key"
#: src/pages/sources/oauth/OAuthSourceForm.ts:130
#: src/pages/sources/oauth/OAuthSourceForm.ts:132
msgid "Consumer secret"
msgstr "Consumer secret"
@ -1107,7 +1107,7 @@ msgstr "Enable TOTP"
#: src/pages/policies/BoundPoliciesList.ts:37
#: src/pages/policies/PolicyBindingForm.ts:198
#: src/pages/sources/ldap/LDAPSourceForm.ts:69
#: src/pages/sources/oauth/OAuthSourceForm.ts:113
#: src/pages/sources/oauth/OAuthSourceForm.ts:115
#: src/pages/sources/saml/SAMLSourceForm.ts:69
msgid "Enabled"
msgstr "Enabled"
@ -1116,7 +1116,7 @@ msgstr "Enabled"
msgid "Enrollment"
msgstr "Enrollment"
#: src/pages/sources/oauth/OAuthSourceForm.ts:196
#: src/pages/sources/oauth/OAuthSourceForm.ts:210
#: src/pages/sources/saml/SAMLSourceForm.ts:266
#: src/pages/stages/identification/IdentificationStageForm.ts:107
msgid "Enrollment flow"
@ -1328,17 +1328,17 @@ msgstr "Flow"
msgid "Flow Overview"
msgstr "Flow Overview"
#: src/pages/sources/oauth/OAuthSourceForm.ts:171
#: src/pages/sources/oauth/OAuthSourceForm.ts:185
#: src/pages/sources/saml/SAMLSourceForm.ts:220
msgid "Flow settings"
msgstr "Flow settings"
#: src/pages/sources/oauth/OAuthSourceForm.ts:193
#: src/pages/sources/oauth/OAuthSourceForm.ts:207
#: src/pages/sources/saml/SAMLSourceForm.ts:263
msgid "Flow to use when authenticating existing users."
msgstr "Flow to use when authenticating existing users."
#: src/pages/sources/oauth/OAuthSourceForm.ts:214
#: src/pages/sources/oauth/OAuthSourceForm.ts:228
#: src/pages/sources/saml/SAMLSourceForm.ts:284
msgid "Flow to use when enrolling new users."
msgstr "Flow to use when enrolling new users."
@ -1718,9 +1718,9 @@ msgstr "Loading"
#: src/pages/providers/saml/SAMLProviderImportForm.ts:55
#: src/pages/sources/ldap/LDAPSourceForm.ts:164
#: src/pages/sources/ldap/LDAPSourceForm.ts:190
#: src/pages/sources/oauth/OAuthSourceForm.ts:163
#: src/pages/sources/oauth/OAuthSourceForm.ts:191
#: src/pages/sources/oauth/OAuthSourceForm.ts:212
#: src/pages/sources/oauth/OAuthSourceForm.ts:177
#: src/pages/sources/oauth/OAuthSourceForm.ts:205
#: src/pages/sources/oauth/OAuthSourceForm.ts:226
#: src/pages/sources/saml/SAMLSourceForm.ts:126
#: src/pages/sources/saml/SAMLSourceForm.ts:240
#: src/pages/sources/saml/SAMLSourceForm.ts:261
@ -1887,7 +1887,7 @@ msgstr "Monitor"
#: src/pages/sources/SourcesListPage.ts:51
#: src/pages/sources/ldap/LDAPSourceForm.ts:54
#: src/pages/sources/ldap/LDAPSourceViewPage.ts:64
#: src/pages/sources/oauth/OAuthSourceForm.ts:98
#: src/pages/sources/oauth/OAuthSourceForm.ts:100
#: src/pages/sources/oauth/OAuthSourceViewPage.ts:63
#: src/pages/sources/saml/SAMLSourceForm.ts:54
#: src/pages/sources/saml/SAMLSourceViewPage.ts:66
@ -2338,7 +2338,7 @@ msgstr "Private key available?"
msgid "Private key, acquired from https://www.google.com/recaptcha/intro/v3.html."
msgstr "Private key, acquired from https://www.google.com/recaptcha/intro/v3.html."
#: src/pages/sources/oauth/OAuthSourceForm.ts:79
#: src/pages/sources/oauth/OAuthSourceForm.ts:80
msgid "Profile URL"
msgstr "Profile URL"
@ -2380,7 +2380,7 @@ msgstr "Property mappings used to user creation."
#: src/pages/providers/oauth2/OAuth2ProviderForm.ts:81
#: src/pages/providers/proxy/ProxyProviderForm.ts:99
#: src/pages/providers/saml/SAMLProviderForm.ts:78
#: src/pages/sources/oauth/OAuthSourceForm.ts:120
#: src/pages/sources/oauth/OAuthSourceForm.ts:122
#: src/pages/sources/saml/SAMLSourceForm.ts:76
msgid "Protocol settings"
msgstr "Protocol settings"
@ -2403,7 +2403,7 @@ msgstr "Provider"
msgid "Provider Type"
msgstr "Provider Type"
#: src/pages/sources/oauth/OAuthSourceForm.ts:136
#: src/pages/sources/oauth/OAuthSourceForm.ts:138
msgid "Provider type"
msgstr "Provider type"
@ -2529,7 +2529,7 @@ msgstr "Request"
msgid "Request has been denied."
msgstr "Request has been denied."
#: src/pages/sources/oauth/OAuthSourceForm.ts:86
#: src/pages/sources/oauth/OAuthSourceForm.ts:87
msgid "Request token URL"
msgstr "Request token URL"
@ -2808,7 +2808,7 @@ msgstr "Skip path regex"
#: src/pages/applications/ApplicationListPage.ts:58
#: src/pages/flows/FlowForm.ts:94
#: src/pages/sources/ldap/LDAPSourceForm.ts:60
#: src/pages/sources/oauth/OAuthSourceForm.ts:104
#: src/pages/sources/oauth/OAuthSourceForm.ts:106
#: src/pages/sources/saml/SAMLSourceForm.ts:60
msgid "Slug"
msgstr "Slug"
@ -3027,7 +3027,7 @@ msgid "Successfully created service-connection."
msgstr "Successfully created service-connection."
#: src/pages/sources/ldap/LDAPSourceForm.ts:47
#: src/pages/sources/oauth/OAuthSourceForm.ts:50
#: src/pages/sources/oauth/OAuthSourceForm.ts:51
#: src/pages/sources/saml/SAMLSourceForm.ts:47
msgid "Successfully created source."
msgstr "Successfully created source."
@ -3163,7 +3163,7 @@ msgid "Successfully updated service-connection."
msgstr "Successfully updated service-connection."
#: src/pages/sources/ldap/LDAPSourceForm.ts:44
#: src/pages/sources/oauth/OAuthSourceForm.ts:47
#: src/pages/sources/oauth/OAuthSourceForm.ts:48
#: src/pages/sources/saml/SAMLSourceForm.ts:44
msgid "Successfully updated source."
msgstr "Successfully updated source."
@ -3425,7 +3425,7 @@ msgstr "UI settings"
msgid "UID"
msgstr "UID"
#: src/pages/sources/oauth/OAuthSourceForm.ts:61
#: src/pages/sources/oauth/OAuthSourceForm.ts:62
msgid "URL settings"
msgstr "URL settings"
@ -3433,19 +3433,19 @@ msgstr "URL settings"
msgid "URL that the initial Login request is sent to."
msgstr "URL that the initial Login request is sent to."
#: src/pages/sources/oauth/OAuthSourceForm.ts:69
#: src/pages/sources/oauth/OAuthSourceForm.ts:70
msgid "URL the user is redirect to to consent the authorization."
msgstr "URL the user is redirect to to consent the authorization."
#: src/pages/sources/oauth/OAuthSourceForm.ts:83
#: src/pages/sources/oauth/OAuthSourceForm.ts:84
msgid "URL used by authentik to get user information."
msgstr "URL used by authentik to get user information."
#: src/pages/sources/oauth/OAuthSourceForm.ts:76
#: src/pages/sources/oauth/OAuthSourceForm.ts:77
msgid "URL used by authentik to retrieve tokens."
msgstr "URL used by authentik to retrieve tokens."
#: src/pages/sources/oauth/OAuthSourceForm.ts:89
#: src/pages/sources/oauth/OAuthSourceForm.ts:90
msgid "URL used to request the initial token. This URL is only required for OAuth 1."
msgstr "URL used to request the initial token. This URL is only required for OAuth 1."

View File

@ -68,7 +68,7 @@ msgstr ""
msgid "Access Key"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:72
#: src/pages/sources/oauth/OAuthSourceForm.ts:73
msgid "Access token URL"
msgstr ""
@ -270,7 +270,7 @@ msgstr ""
msgid "Authentication"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:175
#: src/pages/sources/oauth/OAuthSourceForm.ts:189
#: src/pages/sources/saml/SAMLSourceForm.ts:245
msgid "Authentication flow"
msgstr ""
@ -288,7 +288,7 @@ msgstr ""
msgid "Authorization Code"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:65
#: src/pages/sources/oauth/OAuthSourceForm.ts:66
#: src/pages/sources/oauth/OAuthSourceViewPage.ts:95
msgid "Authorization URL"
msgstr ""
@ -643,11 +643,11 @@ msgstr ""
msgid "Consider Objects matching this filter to be Users."
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:124
#: src/pages/sources/oauth/OAuthSourceForm.ts:126
msgid "Consumer key"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:130
#: src/pages/sources/oauth/OAuthSourceForm.ts:132
msgid "Consumer secret"
msgstr ""
@ -1099,7 +1099,7 @@ msgstr ""
#: src/pages/policies/BoundPoliciesList.ts:37
#: src/pages/policies/PolicyBindingForm.ts:198
#: src/pages/sources/ldap/LDAPSourceForm.ts:69
#: src/pages/sources/oauth/OAuthSourceForm.ts:113
#: src/pages/sources/oauth/OAuthSourceForm.ts:115
#: src/pages/sources/saml/SAMLSourceForm.ts:69
msgid "Enabled"
msgstr ""
@ -1108,7 +1108,7 @@ msgstr ""
msgid "Enrollment"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:196
#: src/pages/sources/oauth/OAuthSourceForm.ts:210
#: src/pages/sources/saml/SAMLSourceForm.ts:266
#: src/pages/stages/identification/IdentificationStageForm.ts:107
msgid "Enrollment flow"
@ -1320,17 +1320,17 @@ msgstr ""
msgid "Flow Overview"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:171
#: src/pages/sources/oauth/OAuthSourceForm.ts:185
#: src/pages/sources/saml/SAMLSourceForm.ts:220
msgid "Flow settings"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:193
#: src/pages/sources/oauth/OAuthSourceForm.ts:207
#: src/pages/sources/saml/SAMLSourceForm.ts:263
msgid "Flow to use when authenticating existing users."
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:214
#: src/pages/sources/oauth/OAuthSourceForm.ts:228
#: src/pages/sources/saml/SAMLSourceForm.ts:284
msgid "Flow to use when enrolling new users."
msgstr ""
@ -1710,9 +1710,9 @@ msgstr ""
#: src/pages/providers/saml/SAMLProviderImportForm.ts:55
#: src/pages/sources/ldap/LDAPSourceForm.ts:164
#: src/pages/sources/ldap/LDAPSourceForm.ts:190
#: src/pages/sources/oauth/OAuthSourceForm.ts:163
#: src/pages/sources/oauth/OAuthSourceForm.ts:191
#: src/pages/sources/oauth/OAuthSourceForm.ts:212
#: src/pages/sources/oauth/OAuthSourceForm.ts:177
#: src/pages/sources/oauth/OAuthSourceForm.ts:205
#: src/pages/sources/oauth/OAuthSourceForm.ts:226
#: src/pages/sources/saml/SAMLSourceForm.ts:126
#: src/pages/sources/saml/SAMLSourceForm.ts:240
#: src/pages/sources/saml/SAMLSourceForm.ts:261
@ -1879,7 +1879,7 @@ msgstr ""
#: src/pages/sources/SourcesListPage.ts:51
#: src/pages/sources/ldap/LDAPSourceForm.ts:54
#: src/pages/sources/ldap/LDAPSourceViewPage.ts:64
#: src/pages/sources/oauth/OAuthSourceForm.ts:98
#: src/pages/sources/oauth/OAuthSourceForm.ts:100
#: src/pages/sources/oauth/OAuthSourceViewPage.ts:63
#: src/pages/sources/saml/SAMLSourceForm.ts:54
#: src/pages/sources/saml/SAMLSourceViewPage.ts:66
@ -2330,7 +2330,7 @@ msgstr ""
msgid "Private key, acquired from https://www.google.com/recaptcha/intro/v3.html."
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:79
#: src/pages/sources/oauth/OAuthSourceForm.ts:80
msgid "Profile URL"
msgstr ""
@ -2372,7 +2372,7 @@ msgstr ""
#: src/pages/providers/oauth2/OAuth2ProviderForm.ts:81
#: src/pages/providers/proxy/ProxyProviderForm.ts:99
#: src/pages/providers/saml/SAMLProviderForm.ts:78
#: src/pages/sources/oauth/OAuthSourceForm.ts:120
#: src/pages/sources/oauth/OAuthSourceForm.ts:122
#: src/pages/sources/saml/SAMLSourceForm.ts:76
msgid "Protocol settings"
msgstr ""
@ -2395,7 +2395,7 @@ msgstr ""
msgid "Provider Type"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:136
#: src/pages/sources/oauth/OAuthSourceForm.ts:138
msgid "Provider type"
msgstr ""
@ -2521,7 +2521,7 @@ msgstr ""
msgid "Request has been denied."
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:86
#: src/pages/sources/oauth/OAuthSourceForm.ts:87
msgid "Request token URL"
msgstr ""
@ -2800,7 +2800,7 @@ msgstr ""
#: src/pages/applications/ApplicationListPage.ts:58
#: src/pages/flows/FlowForm.ts:94
#: src/pages/sources/ldap/LDAPSourceForm.ts:60
#: src/pages/sources/oauth/OAuthSourceForm.ts:104
#: src/pages/sources/oauth/OAuthSourceForm.ts:106
#: src/pages/sources/saml/SAMLSourceForm.ts:60
msgid "Slug"
msgstr ""
@ -3019,7 +3019,7 @@ msgid "Successfully created service-connection."
msgstr ""
#: src/pages/sources/ldap/LDAPSourceForm.ts:47
#: src/pages/sources/oauth/OAuthSourceForm.ts:50
#: src/pages/sources/oauth/OAuthSourceForm.ts:51
#: src/pages/sources/saml/SAMLSourceForm.ts:47
msgid "Successfully created source."
msgstr ""
@ -3155,7 +3155,7 @@ msgid "Successfully updated service-connection."
msgstr ""
#: src/pages/sources/ldap/LDAPSourceForm.ts:44
#: src/pages/sources/oauth/OAuthSourceForm.ts:47
#: src/pages/sources/oauth/OAuthSourceForm.ts:48
#: src/pages/sources/saml/SAMLSourceForm.ts:44
msgid "Successfully updated source."
msgstr ""
@ -3415,7 +3415,7 @@ msgstr ""
msgid "UID"
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:61
#: src/pages/sources/oauth/OAuthSourceForm.ts:62
msgid "URL settings"
msgstr ""
@ -3423,19 +3423,19 @@ msgstr ""
msgid "URL that the initial Login request is sent to."
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:69
#: src/pages/sources/oauth/OAuthSourceForm.ts:70
msgid "URL the user is redirect to to consent the authorization."
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:83
#: src/pages/sources/oauth/OAuthSourceForm.ts:84
msgid "URL used by authentik to get user information."
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:76
#: src/pages/sources/oauth/OAuthSourceForm.ts:77
msgid "URL used by authentik to retrieve tokens."
msgstr ""
#: src/pages/sources/oauth/OAuthSourceForm.ts:89
#: src/pages/sources/oauth/OAuthSourceForm.ts:90
msgid "URL used to request the initial token. This URL is only required for OAuth 1."
msgstr ""

View File

@ -31,6 +31,9 @@ export class OAuthSourceForm extends Form<OAuthSource> {
@property({type: Boolean})
showUrlOptions = false;
@property({type: Boolean})
showRequestTokenURL = false;
getSuccessMessage(): string {
if (this.source) {
return t`Successfully updated source.`;
@ -66,29 +69,30 @@ export class OAuthSourceForm extends Form<OAuthSource> {
label=${t`Authorization URL`}
?required=${true}
name="authorizationUrl">
<input type="text" value="${ifDefined(this.source?.authorizationUrl)}" class="pf-c-form-control" required>
<input type="text" value="${first(this.source?.authorizationUrl, "")}" class="pf-c-form-control" required>
<p class="pf-c-form__helper-text">${t`URL the user is redirect to to consent the authorization.`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${t`Access token URL`}
?required=${true}
name="accessTokenUrl">
<input type="text" value="${ifDefined(this.source?.accessTokenUrl)}" class="pf-c-form-control" required>
<input type="text" value="${first(this.source?.accessTokenUrl, "")}" class="pf-c-form-control" required>
<p class="pf-c-form__helper-text">${t`URL used by authentik to retrieve tokens.`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${t`Profile URL`}
?required=${true}
name="profileUrl">
<input type="text" value="${ifDefined(this.source?.profileUrl)}" class="pf-c-form-control" required>
<input type="text" value="${first(this.source?.profileUrl, "")}" class="pf-c-form-control" required>
<p class="pf-c-form__helper-text">${t`URL used by authentik to get user information.`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
${this.showRequestTokenURL ? html`<ak-form-element-horizontal
label=${t`Request token URL`}
name="requestTokenUrl">
<input type="text" value="${ifDefined(this.source?.requestTokenUrl)}" class="pf-c-form-control">
<input type="text" value="${first(this.source?.requestTokenUrl, "")}" class="pf-c-form-control">
<p class="pf-c-form__helper-text">${t`URL used to request the initial token. This URL is only required for OAuth 1.`}</p>
</ak-form-element-horizontal>
` : html``}
</div>
</ak-form-group>`;
}
@ -144,6 +148,11 @@ export class OAuthSourceForm extends Form<OAuthSource> {
} else {
this.showUrlOptions = false;
}
if ("data-request-token" in selected.attributes) {
this.showRequestTokenURL = true;
} else {
this.showRequestTokenURL = false;
}
if (!this.source) {
this.source = {} as OAuthSource;
}
@ -157,7 +166,13 @@ export class OAuthSourceForm extends Form<OAuthSource> {
selected = true;
}
}
return html`<option ?data-urls-custom=${type.urlsCustomizable} value=${type.slug} ?selected=${selected}>${type.name}</option>`;
return html`<option
?data-urls-custom=${type.urlsCustomizable}
?data-request-token=${type.requestTokenUrl}
value=${type.slug}
?selected=${selected}>
${type.name}
</option>`;
});
}), html`<option>${t`Loading...`}</option>`)}
</select>