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

Should “Enable authentication” and “Enable Custom Auth” create authentication...dbl files #319

Open
mattl91 opened this issue Mar 1, 2023 · 4 comments
Labels
question Further information is requested

Comments

@mattl91
Copy link
Contributor

mattl91 commented Mar 1, 2023

The tutorial https://github.com/Synergex/HarmonyCore/wiki/Tutorial-03-01-Authentication-via-Custom-Code doesn’t work the way it seems it should. The problem is that the files listed in the first two bullets of the “What changed” section aren’t generated when I select the “Enable authentication” and “Enable Custom Auth” options in the GUI tool. Here are the first two bullets of that section:

  • A new source file named AuthenticationModels.dbl is generated into the root folder of the Services.Models project.
  • Two new source files, named AuthenticationController.dbl and AuthenticationTools.dbl, are generated into the root folder of the Services.Controllers project.

If “Enable authentication” and “Enable Custom Auth” are selected in the GUI tool, should the files listed in these two bullets be created?

@mattl91 mattl91 added the question Further information is requested label Mar 1, 2023
@tscaff
Copy link

tscaff commented Jun 16, 2023

Wow, I just saw this question...same as the one I just posted. Did anyone answer your question?

@hippiehunter
Copy link
Contributor

Matt found and fixed it but it will take a little bit before we're ready to do a real update with this in it. in the meantime you can place the following contents into a CustomOData.csx file in the Ganerators\Enabled folder of your solution. If you already have a customization for this generator you should be able to merge the two of them pretty easily.

public class CustomODataGenerator : ODataGenerator
{
    public override void ApplyDefaults(Solution solution)
    {

    }

    public override List<string> ValidateSolution(Solution solution)
    {
        return new List<string>();
    }

    public override List<CodeGenTask> GenerateTasks(Solution solution)
    {
        var baseTasks = base.GenerateTasks(solution);

        if(solution.Authentication ?? false)
            baseTasks.Add(StructureTaskHelper(solution, "Generate custom authentication", solution.ModelsNamespace, solution.ModelsFolder, true, nameof(ODataGenerator), new string[] { "ODataCustomAuthModels" }, null));

        if(solution.CustomAuthentication ?? false)
            baseTasks.Add(StructureTaskHelper(solution, "Generate custom authentication", solution.ControllersNamespace, solution.ControllersFolder, true, nameof(ODataGenerator), new string[] { "ODataCustomAuthController", "ODataCustomAuthTools" }, null));

		return baseTasks;
	}
}

new CustomODataGenerator()

@tscaff
Copy link

tscaff commented Jun 20, 2023

Thanks Jeff, but just to confirm this does impact Traditional Bridge Authentication being enabled....correct? Just wanted to make sure it was not OData only.

@mattl91
Copy link
Contributor Author

mattl91 commented Jun 20, 2023

When you enable authentication, {Authorize} is added to interface controller classes. But this particular update just adds the missing files (AuthenticationModels.dbl, AuthenticationController.dbl, and AuthenticationTools.dbl).

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

No branches or pull requests

3 participants