🔑 Add support for client credentials authentication in API v2.1 with priority over OAuth and API key
This commit is contained in:
@@ -95,6 +95,19 @@
|
|||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Client Credentials (v2.1 only) -->
|
||||||
|
<div v-if="apiVersion === 'v2.1'" class="control-group">
|
||||||
|
<div class="info-badge" v-if="isClientCredsAuthenticated">
|
||||||
|
✓ Client Credentials Active - APPLICATION scope enabled
|
||||||
|
</div>
|
||||||
|
<router-link to="/client-credentials" class="btn btn-secondary btn-sm">
|
||||||
|
Manage Client Credentials
|
||||||
|
</router-link>
|
||||||
|
<span class="scope-hint">
|
||||||
|
Client credentials required for APPLICATION scope access
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -332,6 +345,7 @@
|
|||||||
import { ref, computed, watch, onMounted } from 'vue';
|
import { ref, computed, watch, onMounted } from 'vue';
|
||||||
import { useChallongeApiKey } from '../composables/useChallongeApiKey.js';
|
import { useChallongeApiKey } from '../composables/useChallongeApiKey.js';
|
||||||
import { useChallongeOAuth } from '../composables/useChallongeOAuth.js';
|
import { useChallongeOAuth } from '../composables/useChallongeOAuth.js';
|
||||||
|
import { useChallongeClientCredentials } from '../composables/useChallongeClientCredentials.js';
|
||||||
import {
|
import {
|
||||||
createChallongeV1Client,
|
createChallongeV1Client,
|
||||||
createChallongeV2Client,
|
createChallongeV2Client,
|
||||||
@@ -348,6 +362,10 @@ const {
|
|||||||
logout: oauthLogout,
|
logout: oauthLogout,
|
||||||
loading: oauthLoading
|
loading: oauthLoading
|
||||||
} = useChallongeOAuth();
|
} = useChallongeOAuth();
|
||||||
|
const {
|
||||||
|
isAuthenticated: isClientCredsAuthenticated,
|
||||||
|
accessToken: clientCredsToken
|
||||||
|
} = useChallongeClientCredentials();
|
||||||
|
|
||||||
// API Configuration
|
// API Configuration
|
||||||
const apiVersion = ref('v2.1'); // 'v1' or 'v2.1'
|
const apiVersion = ref('v2.1'); // 'v1' or 'v2.1'
|
||||||
@@ -388,8 +406,15 @@ const client = computed(() => {
|
|||||||
if (!apiKey.value) return null;
|
if (!apiKey.value) return null;
|
||||||
return createChallongeV1Client(apiKey.value);
|
return createChallongeV1Client(apiKey.value);
|
||||||
} else {
|
} else {
|
||||||
// v2.1 supports both OAuth and API key
|
// v2.1 supports OAuth, client credentials, and API key
|
||||||
if (isAuthenticated.value && accessToken.value) {
|
// Priority: Client Credentials > OAuth > API Key
|
||||||
|
if (isClientCredsAuthenticated.value && clientCredsToken.value) {
|
||||||
|
// Use client credentials token (for APPLICATION scope)
|
||||||
|
return createChallongeV2Client(
|
||||||
|
{ token: clientCredsToken.value, type: AuthType.OAUTH },
|
||||||
|
{ debug: debugMode.value }
|
||||||
|
);
|
||||||
|
} else if (isAuthenticated.value && accessToken.value) {
|
||||||
// Use OAuth token if authenticated
|
// Use OAuth token if authenticated
|
||||||
return createChallongeV2Client(
|
return createChallongeV2Client(
|
||||||
{ token: accessToken.value, type: AuthType.OAUTH },
|
{ token: accessToken.value, type: AuthType.OAUTH },
|
||||||
|
|||||||
Reference in New Issue
Block a user