Skip to content

Commit

Permalink
Display authentication type valid values (#3415)
Browse files Browse the repository at this point in the history
also reworked the linter to be native JS not ugly, misshapen bash :P
  • Loading branch information
mooreds authored Dec 9, 2024
1 parent cab4f82 commit 9d94ec1
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
- name: ESLint
run: |
cd astro
bash ../src/scripts/lint-recent-files.sh
npm run lint-pr
shell: /usr/bin/bash -e -o pipefail {0}
3 changes: 2 additions & 1 deletion astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"astro": "astro",
"vale": "./node_modules/@vvago/vale/bin/vale",
"spellcheck": "npm run vale src/content src/components",
"lint": "eslint"
"lint": "eslint",
"lint-pr": "node ../src/scripts/lint-recent-files.mjs"
},
"dependencies": {
"@astro-community/astro-embed-youtube": "^0.4.1",
Expand Down
4 changes: 2 additions & 2 deletions astro/src/content/docs/_shared/_access-token-claims.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import APIBlock from 'src/components/api/APIBlock.astro';
import APIField from 'src/components/api/APIField.astro';
import AuthenticationTypeClaimValues from 'src/content/docs/_shared/_authentication_type_claim_values.mdx';
import AuthenticationTypeClaimValues from 'src/content/docs/_shared/_authentication-type-values.mdx';
import InlineField from 'src/components/InlineField.astro';
import RemovedSince from 'src/components/api/RemovedSince.astro';

Expand All @@ -20,7 +20,7 @@ import RemovedSince from 'src/components/api/RemovedSince.astro';
<APIField name="authenticationType" type="String">
The method used to authenticate the User which resulted in this JWT being generated. The possible values are:

<AuthenticationTypeClaimValues />
<AuthenticationTypeClaimValues show_since="100000" />
</APIField>
<APIField name="auth_time" type="Long" since="1.36.0">
The time of the initial authentication request, expressed as UNIX time which is the number of seconds since Epoch. This claim will remain the same even when the token has been re-issued through the use of a Refresh Token.
Expand Down
36 changes: 36 additions & 0 deletions astro/src/content/docs/_shared/_authentication-type-values.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
# show_since is a 6 digit number
# the first one is the major version
# the next three are the minor version
# the last two are the patch version
# it is used to only show availableSince on feature doc that were created before the authentication type was created. If the authenticationType was added before the feature was added, availableSince makes no sense.
---
import AvailableSince from 'src/components/api/AvailableSince.astro';

* `APPLE` - The User was authenticated using Apple. {props.show_since < 101700 ? <AvailableSince since="1.17.0" /> : ''}
* `APPLICATION_TOKEN` - The User was authenticated using an [Application Authentication Token](/docs/lifecycle/authenticate-users/application-authentication-tokens).
* `EpicGames` -The User was authenticated using Epic Games. {props.show_since < 102800 ? <AvailableSince since="1.28.0" /> : ''}
* `FACEBOOK` - The User was authenticated using Facebook. {props.show_since < 100100 ? <AvailableSince since="1.1.0" /> : ''}
* `FEDERATED_JWT` - The User was authenticated using a JWT from an external Identity Provider.
* `GENERIC_CONNECTOR` - The user was authenticated using a generic connector. {props.show_since < 101800 ? <AvailableSince since="1.18.0" /> : ''}
* `GOOGLE` - The User was authenticated using Google. {props.show_since < 100100 ? <AvailableSince since="1.1.0" /> : ''}
* `HYPR` - The User was authenticated using the HYPR provider. {props.show_since < 101200 ? <AvailableSince since="1.12.0" /> : ''}
* `JWT_SSO` - A valid JWT authorized to one Application was exchanged for another JWT authorized to a different Application.
* `LDAP_CONNECTOR` - The user was authenticated using an LDAP connector. {props.show_since < 101800 ? <AvailableSince since="1.18.0" /> : ''}
* `LINKEDIN` - The user was authenticated using LinkedIn. {props.show_since < 102300 ? <AvailableSince since="1.23.0" /> : ''}
* `Nintendo` - The User was authenticated using Nintendo. {props.show_since < 103600 ? <AvailableSince since="1.36.0" /> : ''}
* `ONE_TIME_PASSWORD` The User was authenticated using a one time password. {props.show_since < 100500 ? <AvailableSince since="1.5.0" /> : ''}
* `OPENID_CONNECT` - The User was authenticated using an external OpenID Connect provider. {props.show_since < 100100 ? <AvailableSince since="1.1.0" /> : ''}
* `PASSWORD` - The User was authenticated using a loginId and password combination.
* `PASSWORDLESS` - The user was authenticated using a passwordless login link. {props.show_since < 100500 ? <AvailableSince since="1.5.0" /> : ''}
* `PING` - The user was authenticated using a `PUT` request on the Login API. This is used to record a login event without prompting for credentials, such as when the FusionAuth SSO session is used.
* `REFRESH_TOKEN` - The User requested a new JWT using a Refresh Token.
* `REGISTRATION` - The user was created using the Registration API. {props.show_since < 101600 ? <AvailableSince since="1.16.0" /> : ''}
* `SAMLv2` - The User was authenticated using an external SAMLv2 provider. {props.show_since < 100600 ? <AvailableSince since="1.6.0" /> : ''}
* `SAMLv2IdpInitiated` - The User was authenticated using an external SAMLv2 provider using an IdP Initiated login. {props.show_since < 102800 ? <AvailableSince since="1.28.0" /> : ''}
* `SonyPSN` - The User was authenticated using Sony {props.show_since < 102800 ? <AvailableSince since="1.28.0" /> : ''}
* `Steam` - The User was authenticated using Steam {props.show_since < 102800 ? <AvailableSince since="1.28.0" /> : ''}
* `TWITTER` - The User was authenticated using Twitter. {props.show_since < 100100 ? <AvailableSince since="1.1.0" /> : ''}
* `Twitch` - The User was authenticated using Twitch {props.show_since < 102800 ? <AvailableSince since="1.28.0" /> : ''}
* `USER_CREATE` - The user was created using the User API. {props.show_since < 101600 ? <AvailableSince since="1.16.0" /> : ''}
* `Xbox` - The User was authenticated using Xbox {props.show_since < 102800 ? <AvailableSince since="1.28.0" /> : ''}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ section: extend
subcategory: code
tertcategory: lambdas
---
import AuthenticationTypeValues from 'src/content/docs/_shared/_authentication-type-values.mdx';
import Breadcrumb from 'src/components/Breadcrumb.astro';
import InlineField from 'src/components/InlineField.astro';

Expand Down Expand Up @@ -45,6 +46,10 @@ The `result` object contains an [Errors](/docs/apis/errors) object. The `user` a
}
```

`authenticationtype` is the method used to authenticate the user. The possible values are:

<AuthenticationTypeValues show_since="105300" />

The `identityProvider` object in the `context` will only be present when the login request is from a 3rd party Identity Provider.

To deny a login attempt, simply add one or more field or general errors to the result. The error schema can be found in the [API Errors](/docs/apis/errors) documentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ subcategory: events and webhooks
tertcategory: events
---
import APIField from 'src/components/api/APIField.astro';
import AuthenticationTypeValues from 'src/content/docs/_shared/_authentication-type-values.mdx';
import Event from 'src/content/docs/extend/events-and-webhooks/events/_event.astro';
import EventBody from 'src/content/docs/extend/events-and-webhooks/events/_event-body.astro';
import InlineField from 'src/components/InlineField.astro';
Expand All @@ -30,7 +31,9 @@ export const eventType = 'user.login.failed';
</APIField>

<APIField slot="leading-fields" name="event.authenticationType" type="String">
The type of authentication used in the login request.
The type of authentication used in the login request. The possible values are:

<AuthenticationTypeValues show_since="100600" />
</APIField>

<APIField slot="leading-fields" name="event.createInstant" type="Long">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ subcategory: events and webhooks
tertcategory: events
---
import APIField from 'src/components/api/APIField.astro';
import AuthenticationTypeValues from 'src/content/docs/_shared/_authentication-type-values.mdx';
import Event from 'src/content/docs/extend/events-and-webhooks/events/_event.astro';
import EventBody from 'src/content/docs/extend/events-and-webhooks/events/_event-body.astro';
import InlineField from 'src/components/InlineField.astro';
Expand All @@ -31,7 +32,9 @@ export const eventType = 'user.login.new-device';
</APIField>

<APIField slot="leading-fields" name="event.authenticationType" type="String">
The type of authentication used in the login request.
The type of authentication used in the login request. The possible values are:

<AuthenticationTypeValues show_since="103000" />
</APIField>

<APIField slot="leading-fields" name="event.connectorId" type="UUID">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ subcategory: events and webhooks
tertcategory: events
---
import APIField from 'src/components/api/APIField.astro';
import AuthenticationTypeValues from 'src/content/docs/_shared/_authentication-type-values.mdx';
import Event from 'src/content/docs/extend/events-and-webhooks/events/_event.astro';
import EventBody from 'src/content/docs/extend/events-and-webhooks/events/_event-body.astro';
import InlineField from 'src/components/InlineField.astro';
Expand All @@ -30,7 +31,9 @@ export const eventType = 'user.login.success';
</APIField>

<APIField slot="leading-fields" name="event.authenticationType" type="String">
The type of authentication used in the login request.
The type of authentication used in the login request. The possible values are:

<AuthenticationTypeValues show_since="100600" />
</APIField>

<APIField slot="leading-fields" name="event.connectorId" type="UUID" since="1.18.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ subcategory: events and webhooks
tertcategory: events
---
import APIField from 'src/components/api/APIField.astro';
import AuthenticationTypeValues from 'src/content/docs/_shared/_authentication-type-values.mdx';
import Event from 'src/content/docs/extend/events-and-webhooks/events/_event.astro';
import EventBody from 'src/content/docs/extend/events-and-webhooks/events/_event-body.astro';
import InlineField from 'src/components/InlineField.astro';
Expand All @@ -31,7 +32,9 @@ export const eventType = 'user.login.suspicious';
</APIField>

<APIField slot="leading-fields" name="event.authenticationType" type="String">
The type of authentication used in the login request.
The type of authentication used in the login request. The possible values are:

<AuthenticationTypeValues show_since="103000" />
</APIField>

<APIField slot="leading-fields" name="event.connectorId" type="UUID">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import APIBlock from 'src/components/api/APIBlock.astro';
import APIField from 'src/components/api/APIField.astro';
import AccessTokenClaims from 'src/content/docs/_shared/_access-token-claims.mdx';
import Aside from 'src/components/Aside.astro';
import AuthenticationTypeClaimValues from 'src/content/docs/_shared/_authentication_type_claim_values.mdx';
import AuthenticationTypeClaimValues from 'src/content/docs/_shared/_authentication-type-values.mdx';
import ExampleAccessToken from 'src/content/docs/lifecycle/authenticate-users/oauth/_example_access_token.mdx';
import ExampleIdToken from 'src/content/docs/lifecycle/authenticate-users/oauth/_example_id_token.mdx';
import ExampleRefreshToken from 'src/content/docs/lifecycle/authenticate-users/oauth/_example_refresh_token.mdx';
Expand Down Expand Up @@ -149,7 +149,7 @@ The Id Token may be returned as part of an Authentication request when the `open
<APIField name="authenticationType" type="String">
The method used to authenticate the User which resulted in this JWT being generated. The possible values are:

<AuthenticationTypeClaimValues />
<AuthenticationTypeClaimValues show_since="100000" />
</APIField>
<APIField name="auth_time" type="Long" since="1.36.0">
The time of the initial authentication request expressed as UNIX time which is the number of seconds since Epoch. This claim will remain the same even when the token has been re-issued through the use of a Refresh Token.
Expand Down
30 changes: 30 additions & 0 deletions src/scripts/lint-recent-files.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { execSync } from 'child_process';

const prNumber = process.env.PR_NUMBER;
if (!prNumber) {
console.error('Error: PR_NUMBER environment variable is not set.');
process.exit(1);
}

const validExtensions = ['js', 'mjs', 'cjs', 'ts', 'md', 'mdx'];
const validStatus = ['added', 'modified'];

// Get the list of changed files in the pull request
const modifiedFilesJson = execSync(`gh api repos/FusionAuth/fusionauth-site/pulls/${prNumber}/files`).toString();
const modifiedFiles = JSON.parse(modifiedFilesJson);

const changedSrcFiles = modifiedFiles
.filter(file => file.filename.startsWith('astro/src/'))
.filter(file => validExtensions.some(ext => file.filename.endsWith(ext)))
.filter(file => validStatus.includes(file.status))
.map(file => file.filename.replace('astro/', ''));

console.log(`Linting changed files: ${changedSrcFiles.join(', ')}`);

try {
const output = execSync(`npm run lint -- ${changedSrcFiles.join(' ')}`);
console.log(output.toString());
} catch (e) {
console.error(e.stdout.toString());
process.exit(1);
}
21 changes: 0 additions & 21 deletions src/scripts/lint-recent-files.sh

This file was deleted.

0 comments on commit 9d94ec1

Please sign in to comment.