Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE OAuth Configuration #858

Closed
wants to merge 20 commits into from
Closed

BE OAuth Configuration #858

wants to merge 20 commits into from

Conversation

alderwhiteford
Copy link
Contributor

Description

[Link to Ticket](insert the link to your ticket inside the parenthesis here)

Please include a summary of the changes and the related issue. Please also
include relevant motivation, context, and images!

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. If they are unit
tests, provide the file name the tests are in. If they are not unit tests,
describe how you tested the change.

Checklist

  • I have performed a self-review of my code
  • I have reached out to another developer to review my code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

@alderwhiteford alderwhiteford changed the title Google sso dashboard BE OAuth Configuration May 20, 2024
Learn about Next.js in an interactive course with quizzes!
</p>
</a>
import { useEffect } from "react";

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import useEffect.
</p>
</a>
import { useEffect } from "react";
import { calendarAuthRedirect } from "@generatesac/lib";

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import calendarAuthRedirect.
const rootReducer = combineReducers({
user: userReducer,
[baseApi.reducerPath]: baseApi.reducer,
clubReducer: clubReducer,

Check warning

Code scanning / CodeQL

Variable not declared before use Warning

Variable 'clubReducer' is used before its
declaration
.
user: userReducer,
[baseApi.reducerPath]: baseApi.reducer,
clubReducer: clubReducer,
recruitmentReducer: recruitmentReducer,

Check warning

Code scanning / CodeQL

Variable not declared before use Warning

Variable 'recruitmentReducer' is used before its
declaration
.
@alderwhiteford
Copy link
Contributor Author

A lot of stuff needs to be removed / moved around

Copy link
Member

@garrettladley garrettladley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're cooking @alderwhiteford

}

// Return the authorization URL:
func (client OAuthClient) Authorize(db *gorm.DB, jwt auth.JWTClientInterface, userId *uuid.UUID) (*string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably be using pointer receivers over value receivers so we don't have to copy the config strings around

Suggested change
func (client OAuthClient) Authorize(db *gorm.DB, jwt auth.JWTClientInterface, userId *uuid.UUID) (*string, error) {
func (client *OAuthClient) Authorize(db *gorm.DB, jwt auth.JWTClientInterface, userId *uuid.UUID) (*string, error) {

**/
func (client GoogleOAuthClient) AuthorizeURL(state string) string {
return (
client.OAuthConfig.BaseURL + "/auth?" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there might be a url builder utility we can use here. if not, we should probably prefer fmt.Sprintf over string concat


func CreateCalendarToken(db *gorm.DB, jwtClient auth.JWTClientInterface, userID *uuid.UUID) (*string, error) {
// Generate CSRF token:
csrfToken, err := jwtClient.GenerateToken(auth.Claims{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to separate concerns on token generation and database transactions, the token should probably be generated in the service, then passed to this function as a string

@@ -246,4 +247,11 @@ CREATE TABLE IF NOT EXISTS verifications(

CREATE UNIQUE INDEX IF NOT EXISTS uni_verifications_token ON verifications USING btree ("token");

CREATE TABLE IF NOT EXISTS user_calendar_token(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's update the [id].down.sql to include a matching drop statement

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but we should split into files for google and outlook. including the associated request bodies there as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there not an associated service and transactions? we should separate our concerns so integrations/oauth only handles the bespoke google/outlook requirements while we have our internal service and transaction logic in this package

@garrettladley
Copy link
Member

A lot of stuff needs to be removed / moved around

didn't see this until after my review, sorry for redundant comments on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants