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

BED-4768 feat: add login handler for OIDC #897

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

BED-4768 feat: add login handler for OIDC #897

wants to merge 3 commits into from

Conversation

mistahj67
Copy link
Contributor

Description

Note: This shouldn't be merged into BED-4851 and should wait until both #896 and #894 are merged. It was just selected as the base for easier PR review.

Add login handler for OIDC

Motivation and Context

This PR addresses: BED-4768

Why is this change required? What problem does it solve?
In order to support OIDC we need to have a generic login handler

How Has This Been Tested?

This is used in conjunction with Authentik locally to verify proper redirection occurred.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have met the contributing prerequisites
  • I have ensured that related documentation is up-to-date
    • Open API docs
    • Code comments (GoDocs / JSDocs)
  • I have followed proper test practices
    • Added/updated tests to cover my changes
    • All new and existing tests passed

@mistahj67 mistahj67 added work in progress This pull request is a work in progress and should not be merged blocked This pull request cannot be completed and should not be merged api A pull request containing changes affecting the API code. labels Oct 4, 2024
@mistahj67 mistahj67 self-assigned this Oct 4, 2024
Comment on lines 61 to 82
func (s *BloodhoundDB) GetSSOProviderBySlug(ctx context.Context, slug string) (model.SSOProvider, error) {
var provider model.SSOProvider
if tx := s.db.WithContext(ctx).Raw(fmt.Sprintf("SELECT id, type, name, slug, created_at, updated_at FROM %s WHERE slug = %s;", ssoProviderTableName, slug)).Scan(&provider); tx.RowsAffected == 0 {
return provider, ErrNotFound
}

return provider, nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to add tests for this db method

Comment on lines +58 to +70

func (s *BloodhoundDB) GetOIDCProviderBySSOProviderID(ctx context.Context, ssoProviderID int32) (model.OIDCProvider, error) {
var oidcProvider model.OIDCProvider
result := s.db.WithContext(ctx).Table(oidcProvidersTableName).Where("sso_provider_id = ?", ssoProviderID).First(&oidcProvider)
return oidcProvider, CheckError(result)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was borrowed from #896

@mistahj67 mistahj67 changed the title feat: add login handler for OIDC BED-4768 feat: add login handler for OIDC Oct 4, 2024
Base automatically changed from BED-4851-oidc-api-provider-registration-2 to main October 9, 2024 20:25
@mistahj67 mistahj67 force-pushed the BED-4768 branch 2 times, most recently from f275bd6 to 24e4f99 Compare October 11, 2024 19:14
@mistahj67 mistahj67 marked this pull request as ready for review October 11, 2024 19:23
@mistahj67 mistahj67 removed the work in progress This pull request is a work in progress and should not be merged label Oct 11, 2024
@mistahj67 mistahj67 force-pushed the BED-4768 branch 2 times, most recently from 6502197 to b606d76 Compare October 16, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api A pull request containing changes affecting the API code. blocked This pull request cannot be completed and should not be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant