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

Add configuration option to control what host is allowed to use FakeAuth #11

Merged
merged 10 commits into from
May 1, 2022

Conversation

floyd-may
Copy link
Collaborator

@floyd-may floyd-may commented Apr 27, 2022

Use case

Building end-to-end testing such that writing e2e tests via Cypress (e.g.) I wouldn't have to instrument logging in via Azure AD, plus I wouldn't have to administer a testing-only AD account (e.g.) in order to validate that my app works correctly when logged in as a certain kind of user. The intent is to control it similar to this so that FakeAuth is only in play when it's needed:

var authBuilder = app.AddAuthentication();
var fakeAuthHost = Configuration["FakeAuthHost"];
if(!string.IsNullOrEmpty(fakeAuthHost)
{
    authBuilder.AddFakeAuth(opts => {
        opts.AllowedHost = fakeAuthHost;
    });
}

I'll likely use something like backend for the FakeAuthHost setting to match what I've configured in, say, a docker-compose.yml file.

I changed the claims serialization as well so that we can set the claims in a textual way instead of the binary serialization scheme that it was using.

(Fixes #13)

@floyd-may
Copy link
Collaborator Author

that build failure makes no sense - aren't I supposed to target Develop?

@calebjenkins
Copy link
Owner

"That build failure makes no sense"
.. agreed. I need to refactor the Workflows so that regression tests run, but right now it forces a fail if it's not actually on the develop branch. My GH Action -fu is weak sauce.

I like the idea of including a list of hosts, other than local. Much better than an on / off flag. I'm trying to think of scenarios where wild cards would be helpful in this scenario.. or if that opens up FA to too many opportunities for abuse.

I'll have time to take look more closely on this later today.

@floyd-may
Copy link
Collaborator Author

Me thinking about what kinds of horrors wildcards would open up:

image

I can get behind doing a list of hosts, though. LMK when you've had a chance to give it a think and if you still like it I'll update the PR accordingly.

@floyd-may
Copy link
Collaborator Author

floyd-may commented Apr 29, 2022

Fixed the GH action thing too 😉

@calebjenkins
Copy link
Owner

@floyd-may I think this CI build to Nuget was published from the PR, it should only be published when a PR is merged to Develop. 😳 https://www.nuget.org/packages/FakeAuth/1.2.0-ci-61

@floyd-may
Copy link
Collaborator Author

@calebjenkins this ought to be ready to go. Also performed necessary incantations to get the ci actions workflow to only push to NuGet on the Develop branch.


- name: Pack
run: dotnet pack --configuration Release /p:Version=${{steps.get_version.outputs.RELEASE_VERSION}}-ci-${BUILD_NUMBER} --include-symbols --output .
if: ${{ steps.detect_develop.outcome == 'success' }}
Copy link
Owner

Choose a reason for hiding this comment

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

This is beautiful! 🤩🤩 So elegant!

@calebjenkins calebjenkins merged commit dfa039d into Develop May 1, 2022
@floyd-may floyd-may deleted the allow-non-localhost branch May 1, 2022 13:25
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