Skip to content

Commit

Permalink
Correct usage of "authorized"/"authorization" (#7786)
Browse files Browse the repository at this point in the history
In many cases what is actually meant is
"authenticated"/"authentication". This patch fixes such mistakes across
the codebase.
  • Loading branch information
SpecLad authored Apr 25, 2024
1 parent eaf0e9a commit 2da1646
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 85 deletions.
4 changes: 2 additions & 2 deletions cvat-core/src/api-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export default function implementAPI(cvat: CVATCore): CVATCore {
implementationMixin(cvat.server.resetPassword, async (newPassword1, newPassword2, uid, token) => {
await serverProxy.server.resetPassword(newPassword1, newPassword2, uid, token);
});
implementationMixin(cvat.server.authorized, async () => {
const result = await serverProxy.server.authorized();
implementationMixin(cvat.server.authenticated, async () => {
const result = await serverProxy.server.authenticated();
return result;
});
implementationMixin(cvat.server.healthCheck, async (
Expand Down
4 changes: 2 additions & 2 deletions cvat-core/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ function build(): CVATCore {
);
return result;
},
async authorized() {
const result = await PluginRegistry.apiWrapper(cvat.server.authorized);
async authenticated() {
const result = await PluginRegistry.apiWrapper(cvat.server.authenticated);
return result;
},
async healthCheck(maxRetries = 1, checkPeriod = 3000, requestTimeout = 5000, progressCallback = undefined) {
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default interface CVATCore {
changePassword: any;
requestPasswordReset: any;
resetPassword: any;
authorized: any;
authenticated: any;
healthCheck: any;
request: any;
setAuthData: any;
Expand Down
4 changes: 2 additions & 2 deletions cvat-core/src/server-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ async function getSelf(): Promise<SerializedUser> {
return response.data;
}

async function authorized(): Promise<boolean> {
async function authenticated(): Promise<boolean> {
try {
// In CVAT app we use two types of authentication
// At first we check if authentication token is present
Expand Down Expand Up @@ -2423,7 +2423,7 @@ export default Object.freeze({
changePassword,
requestPasswordReset,
resetPassword,
authorized,
authenticated,
healthCheck,
register,
request: serverRequest,
Expand Down
4 changes: 2 additions & 2 deletions cvat-sdk/gen/templates/openapi-generator/api_doc.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ The second value is the raw response, which can be useful to get response parame
status code, headers, or raw response data. Read more about invocation parameters
and returned values [here](https://docs.cvat.ai/docs/api_sdk/sdk/lowlevel-api/#sending-requests).

### Authorization
### Authentication

{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}{{{name}}}{{^-last}}, {{/-last}}{{/authMethods}}
{{^authMethods}}No authentication required{{/authMethods}}{{#authMethods}}{{{name}}}{{^-last}}, {{/-last}}{{/authMethods}}

### HTTP request headers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Configuration:

API Key Authentication Example.

You can authorize with API token after doing the basic auth the following way:
You can authenticate with API token after doing the basic auth the following way:

conf = {{{packageName}}}.Configuration(
...
Expand Down
24 changes: 12 additions & 12 deletions cvat-ui/src/actions/auth-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { getCore, User } from 'cvat-core-wrapper';
const cvat = getCore();

export enum AuthActionTypes {
AUTHORIZED_REQUEST = 'AUTHORIZED_REQUEST',
AUTHORIZED_SUCCESS = 'AUTHORIZED_SUCCESS',
AUTHORIZED_FAILED = 'AUTHORIZED_FAILED',
AUTHENTICATED_REQUEST = 'AUTHENTICATED_REQUEST',
AUTHENTICATED_SUCCESS = 'AUTHENTICATED_SUCCESS',
AUTHENTICATED_FAILED = 'AUTHENTICATED_FAILED',
LOGIN = 'LOGIN',
LOGIN_SUCCESS = 'LOGIN_SUCCESS',
LOGIN_FAILED = 'LOGIN_FAILED',
Expand All @@ -35,9 +35,9 @@ export enum AuthActionTypes {
}

export const authActions = {
authorizeRequest: () => createAction(AuthActionTypes.AUTHORIZED_REQUEST),
authorizeSuccess: (user: User | null) => createAction(AuthActionTypes.AUTHORIZED_SUCCESS, { user }),
authorizeFailed: (error: any) => createAction(AuthActionTypes.AUTHORIZED_FAILED, { error }),
authenticatedRequest: () => createAction(AuthActionTypes.AUTHENTICATED_REQUEST),
authenticatedSuccess: (user: User | null) => createAction(AuthActionTypes.AUTHENTICATED_SUCCESS, { user }),
authenticatedFailed: (error: any) => createAction(AuthActionTypes.AUTHENTICATED_FAILED, { error }),
login: () => createAction(AuthActionTypes.LOGIN),
loginSuccess: (user: User) => createAction(AuthActionTypes.LOGIN_SUCCESS, { user }),
loginFailed: (error: any, hasEmailVerificationBeenSent = false) => (
Expand Down Expand Up @@ -120,18 +120,18 @@ export const logoutAsync = (): ThunkAction => async (dispatch) => {
}
};

export const authorizedAsync = (): ThunkAction => async (dispatch) => {
export const authenticatedAsync = (): ThunkAction => async (dispatch) => {
try {
dispatch(authActions.authorizeRequest());
const result = await cvat.server.authorized();
dispatch(authActions.authenticatedRequest());
const result = await cvat.server.authenticated();
if (result) {
const userInstance = (await cvat.users.get({ self: true }))[0];
dispatch(authActions.authorizeSuccess(userInstance));
dispatch(authActions.authenticatedSuccess(userInstance));
} else {
dispatch(authActions.authorizeSuccess(null));
dispatch(authActions.authenticatedSuccess(null));
}
} catch (error) {
dispatch(authActions.authorizeFailed(error));
dispatch(authActions.authenticatedFailed(error));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ export default function CreateCloudStorageForm(props: Props): JSX.Element {
<Input disabled={!!cloudStorage} maxLength={63} />
</Form.Item>
<Form.Item
label='Authorization type'
label='Authentication type'
name='credentials_type'
rules={[{ required: true, message: 'Please, specify credentials type' }]}
{...internalCommonProps}
Expand Down Expand Up @@ -555,7 +555,7 @@ export default function CreateCloudStorageForm(props: Props): JSX.Element {
<Input disabled={!!cloudStorage} maxLength={63} />
</Form.Item>
<Form.Item
label='Authorization type'
label='Authentication type'
name='credentials_type'
rules={[{ required: true, message: 'Please, specify credentials type' }]}
{...internalCommonProps}
Expand Down Expand Up @@ -593,7 +593,7 @@ export default function CreateCloudStorageForm(props: Props): JSX.Element {
<Input disabled={!!cloudStorage} maxLength={222} />
</Form.Item>
<Form.Item
label='Authorization type'
label='Authentication type'
name='credentials_type'
rules={[{ required: true, message: 'Please, specify credentials type' }]}
{...internalCommonProps}
Expand Down
6 changes: 3 additions & 3 deletions cvat-ui/src/components/cvat-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import InvitationWatcher from './invitation-watcher/invitation-watcher';
interface CVATAppProps {
loadFormats: () => void;
loadAbout: () => void;
verifyAuthorized: () => void;
verifyAuthenticated: () => void;
loadUserAgreements: () => void;
initPlugins: () => void;
initModels: () => void;
Expand Down Expand Up @@ -255,7 +255,7 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP

public componentDidUpdate(prevProps: CVATAppProps): void {
const {
verifyAuthorized,
verifyAuthenticated,
loadFormats,
loadAbout,
loadUserAgreements,
Expand Down Expand Up @@ -297,7 +297,7 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
this.showMessages();

if (!userInitialized && !userFetching) {
verifyAuthorized();
verifyAuthenticated();
return;
}

Expand Down
6 changes: 3 additions & 3 deletions cvat-ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { connect, Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';

import { getAboutAsync } from 'actions/about-actions';
import { authorizedAsync } from 'actions/auth-actions';
import { authenticatedAsync } from 'actions/auth-actions';
import { getFormatsAsync } from 'actions/formats-actions';
import { getModelsAsync } from 'actions/models-actions';
import { getPluginsAsync } from 'actions/plugins-actions';
Expand Down Expand Up @@ -59,7 +59,7 @@ interface StateToProps {

interface DispatchToProps {
loadFormats: () => void;
verifyAuthorized: () => void;
verifyAuthenticated: () => void;
loadAbout: () => void;
initModels: () => void;
initPlugins: () => void;
Expand Down Expand Up @@ -107,7 +107,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
function mapDispatchToProps(dispatch: any): DispatchToProps {
return {
loadFormats: (): void => dispatch(getFormatsAsync()),
verifyAuthorized: (): void => dispatch(authorizedAsync()),
verifyAuthenticated: (): void => dispatch(authenticatedAsync()),
loadUserAgreements: (): void => dispatch(getUserAgreementsAsync()),
initPlugins: (): void => dispatch(getPluginsAsync()),
initModels: (): void => dispatch(getModelsAsync()),
Expand Down
6 changes: 3 additions & 3 deletions cvat-ui/src/reducers/auth-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ const defaultState: AuthState = {

export default function (state = defaultState, action: AuthActions | BoundariesActions): AuthState {
switch (action.type) {
case AuthActionTypes.AUTHORIZED_REQUEST:
case AuthActionTypes.AUTHENTICATED_REQUEST:
return {
...state,
fetching: true,
initialized: false,
};
case AuthActionTypes.AUTHORIZED_SUCCESS:
case AuthActionTypes.AUTHENTICATED_SUCCESS:
return {
...state,
initialized: true,
fetching: false,
user: action.payload.user,
};
case AuthActionTypes.AUTHORIZED_FAILED:
case AuthActionTypes.AUTHENTICATED_FAILED:
return {
...state,
fetching: false,
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/src/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ export interface ErrorState {
export interface NotificationsState {
errors: {
auth: {
authorized: null | ErrorState;
authenticated: null | ErrorState;
login: null | ErrorState;
logout: null | ErrorState;
register: null | ErrorState;
Expand Down
8 changes: 4 additions & 4 deletions cvat-ui/src/reducers/notifications-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { NotificationsState } from '.';
const defaultState: NotificationsState = {
errors: {
auth: {
authorized: null,
authenticated: null,
login: null,
logout: null,
register: null,
Expand Down Expand Up @@ -212,15 +212,15 @@ const defaultState: NotificationsState = {

export default function (state = defaultState, action: AnyAction): NotificationsState {
switch (action.type) {
case AuthActionTypes.AUTHORIZED_FAILED: {
case AuthActionTypes.AUTHENTICATED_FAILED: {
return {
...state,
errors: {
...state.errors,
auth: {
...state.errors.auth,
authorized: {
message: 'Could not check authorization on the server',
authenticated: {
message: 'Could not check authentication on the server',
reason: action.payload.error,
shouldLog: !(action.payload.error instanceof ServerError),
},
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/cloud_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def __init__(self,
)
== 1
):
raise Exception("Insufficient data for authorization")
raise Exception("Insufficient data for authentication")

kwargs = dict()
for key, arg_v in zip(
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2394,7 +2394,7 @@ def get_serializer_class(self):
@action(detail=False, methods=['GET'])
def self(self, request):
"""
Method returns an instance of a user who is currently authorized
Method returns an instance of a user who is currently authenticated
"""
serializer_class = self.get_serializer_class()
serializer = serializer_class(request.user, context={ "request": request })
Expand Down
4 changes: 2 additions & 2 deletions cvat/apps/iam/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def unsign(self, signature, url):
except User.DoesNotExist:
raise signing.BadSignature()

# Even with token authorization it is very important to have a valid session id
# in cookies because in some cases we cannot use token authorization (e.g. when
# Even with token authentication it is very important to have a valid session id
# in cookies because in some cases we cannot use token authentication (e.g. when
# we redirect to the server in UI using just URL). To overkill that we override
# the class to call `login` method which restores the session id in cookies.
class TokenAuthenticationEx(TokenAuthentication):
Expand Down
2 changes: 1 addition & 1 deletion cvat/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5684,7 +5684,7 @@ paths:
/api/users/self:
get:
operationId: users_retrieve_self
description: Method returns an instance of a user who is currently authorized
description: Method returns an instance of a user who is currently authenticated
summary: Get details of the current user
tags:
- users
Expand Down
2 changes: 1 addition & 1 deletion cvat/settings/testing_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from cvat.settings.production import *

# We use MD5 password hasher instead of default PBKDF2 here to speed up REST API tests,
# because the current implementation of the tests requires a authorization in each test case
# because the current implementation of the tests requires authentication in each test case
# so using the PBKDF2 hasher slows them.
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.MD5PasswordHasher",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Make a request to a resource stored on a server and the server will respond with
The HTTP protocol is used to transport a data.
Requests are divided into groups:

- `auth` - user authorization queries
- `auth` - user authentication queries
- `comments` - requests to post/delete comments to issues
- `issues` - update, delete and view problem comments
- `jobs` -requests to manage the job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ There are 2 basic steps to enable GitHub account authentication.
2. On the left menu, click **<> Developer settings** > **OAuth Apps** > **Register new application**.
<br>For more information, see [Creating an OAuth App](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)
3. Fill in the name field, set the homepage URL (for example: `https://localhost:8080`),
and authorization callback URL (for example: `https://localhost:8080/api/auth/social/github/login/callback/`).
and authentication callback URL (for example: `https://localhost:8080/api/auth/social/github/login/callback/`).
4. Create conпiguration file in CVAT:

1. Create the `auth_config.yml` file with the following content:
Expand Down Expand Up @@ -113,7 +113,7 @@ To enable authentication, do the following:
1. Create a user pool. For more information,
see [Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html)
2. Fill in the name field, set the homepage URL (for example: `https://localhost:8080`),
and authorization callback URL (for example: `https://localhost:8080/api/auth/social/amazon-cognito/login/callback/`).
and authentication callback URL (for example: `https://localhost:8080/api/auth/social/amazon-cognito/login/callback/`).
3. Create conпiguration file in CVAT:

1. Create the `auth_config.yml` file with the following content:
Expand Down
Loading

0 comments on commit 2da1646

Please sign in to comment.