Skip to content

Commit

Permalink
feat(keycloak-auth): Make basic auth as defautl option and updated th…
Browse files Browse the repository at this point in the history
…e Co-pilot usage disclaimer

Signed-off-by: Smruti Prakash Sahoo <[email protected]>
  • Loading branch information
smrutis1 committed Sep 24, 2024
1 parent 70738d2 commit 28d78cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/app/api/auth/[...nextauth]/authOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import sw360OauthPwdGrantTypeOption from './sw360OauthPwdGrantTypeOption';
let authOptions: NextAuthOptions

switch (AUTH_PROVIDER) {
case 'sw360basic':
authOptions = basicAuthOption
break;
case 'sw360oauth':
authOptions = sw360OauthOption
break;
Expand All @@ -31,7 +28,9 @@ switch (AUTH_PROVIDER) {
case 'oauth-password-grant':
authOptions = sw360OauthPwdGrantTypeOption
break;
case 'sw360basic':
default:
authOptions = basicAuthOption
break;
}

Expand Down
6 changes: 2 additions & 4 deletions src/app/api/auth/[...nextauth]/sw360OauthOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// SPDX-License-Identifier: EPL-2.0
// License-Filename: LICENSE

// Some portions generated by Co-Pilot

import { SW360User } from '../../../../../nextauth'
import crypto from 'crypto';
import { SW360_API_URL, SW360_REST_CLIENT_ID, SW360_REST_CLIENT_SECRET } from '@/utils/env';
Expand All @@ -24,7 +26,6 @@ const sw360OauthOption: NextAuthOptions = {
wellKnown: SW360_API_URL + "/authorization/.well-known/oauth-authorization-server",
checks: ["pkce", "state"],
idToken: true,
// Partial GH Copilot generated- start
authorization: {
params: {
scope: "openid READ WRITE ADMIN", code_challenge_method: "S256", code_challenge: (() => {
Expand All @@ -34,7 +35,6 @@ const sw360OauthOption: NextAuthOptions = {
})(),
}
},
// Partial GH Copilot generated- end
clientId: SW360_REST_CLIENT_ID,
clientSecret: SW360_REST_CLIENT_SECRET,
profile: async (profiles, tokens) => {
Expand Down Expand Up @@ -74,7 +74,6 @@ const sw360OauthOption: NextAuthOptions = {
},
}

// GH Copilot generated- start
function codeVerifierGenerator() {
const randomBytes = crypto.randomBytes(32);
const verifier = base64urlEncode(randomBytes);
Expand All @@ -94,6 +93,5 @@ function codeChallengeGenerator(verifier: crypto.BinaryLike) {
const challenge = base64urlEncode(hash);
return challenge;
}
// GH Copilot generated- end

export default sw360OauthOption;

0 comments on commit 28d78cd

Please sign in to comment.