Skip to content

Commit

Permalink
update of some deps + fixed cookie bug #1
Browse files Browse the repository at this point in the history
* Updated `Readme`
* Fixed cookie bug
* Added `Jira OAuth` support
* Updated dependencies:
	* `Bootstrap` and `Bootswatch`: `4` to `5` major release
	* `jQuery` minor update to `3.7.1`
	* `fontawesome`: `5` to `6` major release
	* `Atlassian SDK` to `13.0.0` version
* migtateed to bs5 and rebase this commit
  • Loading branch information
stamepicmorg committed Sep 23, 2024
1 parent ce30acb commit 257ab40
Show file tree
Hide file tree
Showing 4,298 changed files with 1,098,931 additions and 1,722 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Changelog
## 2024
* `sep`
* `2.0.0.0` - New Major release:
* Migrated to `dotnet8`
* Updated `Readme`
* Fixed cookie bug
* Added `Jira OAuth` support
* Updated dependencies:
* `Bootstrap` and `Bootswatch`: `4` to `5` major release
* `jQuery` minor update to `3.7.1`
* `fontawesome`: `5` to `6` major release
* `Atlassian SDK` to `13.0.0` version
* `1.0.0.17` - public release
* `WIP`: migrating to `dotnet8` and bugfixes.
-------------------------------------------------------------------
## 2020
* `1.0.0.17` - internal stable release.
Expand Down
136 changes: 134 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,82 @@

Jira Quick Issue Creator - webtool for quick creation and checking issues from Jira instance by customers.

### Supported themes:
## Supported Platforms:
* Checked with `Jira Server and DataCenter` editions and versions from `7.x` to `10.x` with `JiraAuthTypeBasic`.
* Cloud versions `technically` supported via `JiraAuthTypeOAuth` but *NOT* tested.

# Full `appsettings.json` example:

```
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Jira": {
"Domain": "",
"AuthType": "Basic", //Oauth
"JiraAuthTypeBasic": {
"Login": "",
"Password": ""
},
"JiraAuthTypeOAuth": {
"ConsumerKey": "",
"ConsumerSecret": "",
"AccessToken": "",
"TokenSecret": ""
},
"AllowedProjects": [
"",
""
],
"AllowedIssueTypes": [
"",
""
]
},
"UI": {
"Theme": "",
"LogoUrl": "",
"HeaderText": "",
"DescriptionText": "",
"LicensedTo": ""
},
"Captcha": {
"key": "",
"secret": ""
}
}
```

### Descriptions of some options

* `AuthType` - kind of auth type. `Basic` or `OAuth`. How to setup `OAuth` - described [here](https://developer.atlassian.com/server/jira/platform/oauth/).
* `Captcha` - is optionan section. Official google Captcha docs [here](https://www.google.com/recaptcha/about/).
* `AllowedProjects` - list of allowed projects to connect. Use `Jira's Project Key`.
* `AllowedIssueTypes` - list of allowed project types to connect. Kind of `Bug`, `Task`, etc. Get names from your Jira Admin section of instance.

### Logging
File `appSettings.json` contains additional settings, like [loglevel](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-5.0#fields) and [console output theme](https://github.com/serilog/serilog-sinks-console). You can set it up via editing this file.

#### Supported log levels
| Level | Enum | Description
|-------------|:-------------:|-------------|
| `Critical` | `5` | Logs that describe an unrecoverable application or system crash, or a catastrophic failure that requires immediate attention.
| `Debug` | `1` | Logs that are used for interactive investigation during development. These logs should primarily contain information useful for debugging and have no long-term value.
| `Error` | `4` | Logs that highlight when the current flow of execution is stopped due to a failure. These should indicate a failure in the current activity, not an application-wide failure.
| `Information` | `2` | Logs that track the general flow of the application. These logs should have long-term value.
| `None` | `6` | Not used for writing log messages. Specifies that a logging category should not write any messages.
| `Trace` | `0` | Logs that contain the most detailed messages. These messages may contain sensitive application data. These messages are disabled by default and should never be enabled in a production environment.
| `Warning` | `3` | Logs that highlight an abnormal or unexpected event in the application flow, but do not otherwise cause the application execution to stop.


### Themes:

Set theme in UI section of appsettings.json:

Expand All @@ -17,7 +92,7 @@ Set theme in UI section of appsettings.json:
```
of via enviroment-file vars or compose-file:
```
- UI_Theme: default
- UI__Theme: default
```

Themes:
Expand All @@ -33,7 +108,9 @@ Themes:
* `lux`
* `materia`
* `minty`
* `morph`
* `pulse`
* `quartz`
* `sandstone`
* `simplex`
* `sketchy`
Expand All @@ -42,10 +119,65 @@ Themes:
* `spacelab`
* `superhero`
* `united`
* `vapor`
* `yeti`
* `zephyr`

You cah check live demos at official https://bootswatch.com/ site.

## Setup envs

1. Read officia Microsoft docs [here](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-8.0)
2. Setup.

### ENV example (docker-compose.yml):

```
- AllowedHosts: "*"
<...>
- UI__LicensedTo: "Me"
- UI__Theme: "darkly"
- UI__HeaderText: "Header"
- UI__DescriptionText: "Description"
<...>
- Jira__Domain: "https://my-selfhosted-jira.local"
- Jira__AuthType: "Basic"
- Jira__AuthType__JiraAuthTypeBasic__Login: "my-user"
- Jira__AuthType__JiraAuthTypeBasic__Password: my-user-password"
- Jira__AllowedProjects__0: "KEY0"
- Jira__AllowedProject__1: "KEY1"
- Jira__AllowedIssueTypes__0: "Bug"
- Jira__AllowedIssueTypes__1: "Support"
- Jira__AllowedIssueTypes__2: "Feedback"
- Jira__AllowedIssueTypes__3: "Story"
<...>
- Captcha__key: "key"
- Captcha__secret: "secret"
<...>
```

#### example

```
```

# Used componets:
| Compoment | Link | Version |
|---------------------------------|-----------------------------------------------------|-----------|
| .NET 8 (ASP.NET Core) | [dotnet.microsoft.com](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) | 8.0 |
| jQuery | [jquery.com](https://jquery.com/) | 3.7.1 |
| jQuery Localization Plugin | [github.com/coderifous/jquery-localize](https://github.com/coderifous/jquery-localize) | 0.2.0 |
| jQuery Validation Plugin | [github.com/jquery-validation/jquery-validation](https://github.com/jquery-validation/jquery-validation) | 1.19.3 |
| jQuery Validation Unobtrusive | [github.com/aspnet/jquery-validation-unobtrusive](https://github.com/aspnet/jquery-validation-unobtrusive) | 3.2.12 |
| Bootstrap | [getbootstrap.com](https://getbootstrap.com/) | 5.3.3 |
| Bootswatch | [bootswatch.com](https://bootswatch.com/) | 5.3 |
| FontAwesome | [fontawesome.com](https://fontawesome.com/) | 6.6.0 |
| Flaticon (Freepik) | [flaticon.com/authors/freepik](https://www.flaticon.com/authors/freepik) | - |

Если нужно внести изменения или дополнить информацию, дайте знать!

# [Stargazers](https://github.com/EpicMorg/jira-issue-web-reporter/stargazers)

# [Forkers](https://github.com/EpicMorg/jira-issue-web-reporter/network/members)
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#version: '3'
services:
app:
image: "epicmorg/jira-issue-web-reporter-docker:latest"
build:
context: .
services:
app-develop:
image: "epicmorg/jira-issue-web-reporter-docker:develop"
build:
context: .
41 changes: 36 additions & 5 deletions src/Models/Configuration/JiraConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,50 @@
public class JiraConfig
{
[Url]
public string Domain { get; set; }
public required string Domain { get; set; }

[Required]
public string Login { get; set; }
public required string[] AllowedProjects { get; set; }

[Required]
public string Password { get; set; }
public required string[] AllowedIssueTypes { get; set; }

[Required]
public string[] AllowedProjects { get; set; }
public required JiraAuthTypes AuthType { get; set; }

public JiraAuthTypeBasic? JiraAuthTypeBasic { get; set; }
public JiraAuthTypeOAuth? JiraAuthTypeOAuth { get; set; }
}

public class JiraAuthTypeBasic
{
[Required]
public required string Login { get; set; }

[Required]
public required string Password { get; set; }

}

public class JiraAuthTypeOAuth
{
[Required]
public string[] AllowedIssueTypes { get; set; }
public required string ConsumerKey { get; set; }

[Required]
public required string ConsumerSecret { get; set; }

[Required]
public required string AccessToken { get; set; }

[Required]
public required string TokenSecret { get; set; }

}

public enum JiraAuthTypes
{
OAuth,
Basic,
}
}
30 changes: 22 additions & 8 deletions src/Services/DI/AtlassianExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using epicmorg.jira.issue.web.reporter.Models.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System;

public static class AtlassianExtensions
{
Expand All @@ -12,14 +13,27 @@ public static IServiceCollection AddJira(this IServiceCollection services)
services.AddScoped<Jira>(context =>
{
var jiraOptions = context.GetService<IOptions<JiraConfig>>().Value;
var client = Jira.CreateRestClient(
jiraOptions.Domain,
jiraOptions.Login,
jiraOptions.Password,
new JiraRestClientSettings
{
Cache = new Atlassian.Jira.JiraCache(),
});
var client = jiraOptions.AuthType switch
{
JiraAuthTypes.Basic => Jira.CreateRestClient(
url: jiraOptions.Domain,
username: jiraOptions.JiraAuthTypeBasic.Login,
password: jiraOptions.JiraAuthTypeBasic.Password,
settings: new JiraRestClientSettings
{
Cache = new Atlassian.Jira.JiraCache(),
}),
JiraAuthTypes.OAuth => Jira.CreateOAuthRestClient(
url: jiraOptions.Domain,
consumerKey: jiraOptions.JiraAuthTypeOAuth.ConsumerKey,
consumerSecret: jiraOptions.JiraAuthTypeOAuth.ConsumerSecret,
oAuthAccessToken: jiraOptions.JiraAuthTypeOAuth.AccessToken,
oAuthTokenSecret: jiraOptions.JiraAuthTypeOAuth.TokenSecret),
_ => throw new Exception($"Invalid auth type!: {jiraOptions.AuthType}")
};
return client;
});
return services;
Expand Down
10 changes: 7 additions & 3 deletions src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace epicmorg.jira.issue.web.reporter
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;

public class Startup
{
Expand Down Expand Up @@ -41,7 +42,9 @@ public void ConfigureServices(IServiceCollection services)
.AddAntiforgery(o =>
{
o.SuppressXFrameOptionsHeader = true;
o.Cookie.SameSite = SameSiteMode.None;
// o.Cookie.SameSite = SameSiteMode.None;
// o.Cookie.HttpOnly = true;
//o.Cookie.SecurePolicy = CookieSecurePolicy.Always;
})
.AddHttpClient()
.AddHttpClient<ICaptchaValidator, GoogleRecaptchaValidator>();
Expand Down Expand Up @@ -73,8 +76,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseRouting();

app.UseAuthorization();

// Some legacy
//app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
Expand Down
12 changes: 6 additions & 6 deletions src/Views/Home/Check.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@model CheckRequest
<form asp-action="Check" id="form" asp-all-route-data="new Dictionary<string, string>()">
<div class="mb-3">
<div class="form-group">
<div class="">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<label asp-for="Issue"><i class="fas fa-keyboard"></i> <span data-localize="label-enter-issue-key">Enter issue key</span>:</label>
<input type="text" asp-for="Issue" class="form-control" placeholder="ABC-123" value="" required>
Expand All @@ -11,20 +11,20 @@
</div>

<div class="mb-3">
<div class="form-group">
<div class="">
<div class="g-recaptcha" data-sitekey="@captchaConfig.Value.Key" data-callback="recaptchaCallback"></div>
</div>
<span asp-validation-for="Captcha" class="text-danger"></span>
</div>

<div class="form-group">
<button class="btn btn-primary btn-lg btn-block" type="submit"><span data-localize="label-check">Check</span> <i class="fas fa-hand-pointer"></i></button>
<div class="">
<button class="btn btn-primary btn-lg w-100" type="submit"><span data-localize="label-check">Check</span> <i class="fas fa-hand-pointer"></i></button>
</div>
</form>

@section Head {
<script src='https://www.google.com/recaptcha/api.js'></script>
}
@section Scripts{
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}
}
Loading

0 comments on commit 257ab40

Please sign in to comment.