Compare commits
9 Commits
APIDEV-0.1
...
15f5e43e34
| Author | SHA1 | Date | |
|---|---|---|---|
| 15f5e43e34 | |||
| 6634891de6 | |||
| 98fc970653 | |||
| f71211c0b9 | |||
| 19fab91db9 | |||
| 8b9a837062 | |||
| be1344e9e5 | |||
| fc51e2eda9 | |||
| 456b8ef75b |
@ -9,7 +9,7 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- rm -f tags.txt
|
- rm -f tags.txt
|
||||||
- echo ${CI_COMMIT_TAG} | sed -e "s/^APIDEV-//" >> tags.txt
|
- echo ${CI_COMMIT_TAG} | sed -e "s/^APIDEV-//" >> tags.txt
|
||||||
- echo "latest-dev" >> tags.txt
|
- echo "latest-dev"
|
||||||
- name: (YABA.API) Determining Docker image version number (prod)
|
- name: (YABA.API) Determining Docker image version number (prod)
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
when:
|
when:
|
||||||
@ -17,7 +17,7 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- rm -f tags.txt
|
- rm -f tags.txt
|
||||||
- echo ${CI_COMMIT_TAG} | sed -e "s/^API-//" >> tags.txt
|
- echo ${CI_COMMIT_TAG} | sed -e "s/^API-//" >> tags.txt
|
||||||
- echo "latest" >> tags.txt
|
- echo "latest"
|
||||||
- name: (YABA.API) Package and Upload Docker Image
|
- name: (YABA.API) Package and Upload Docker Image
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
settings:
|
settings:
|
||||||
|
|||||||
@ -4,23 +4,21 @@ when:
|
|||||||
steps:
|
steps:
|
||||||
- name: (YABA.Web) Determining Docker image version number (dev)
|
- name: (YABA.Web) Determining Docker image version number (dev)
|
||||||
when:
|
when:
|
||||||
- ref: refs/tags/WEBDEV-*
|
- refs: refs/tags/WEBDEV-*
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
commands:
|
commands:
|
||||||
- rm -f tags.txt
|
- rm -f tags.txt
|
||||||
- echo ${CI_COMMIT_TAG} | sed -e "s/^WEBDEV-//" >> tags.txt
|
- echo ${CI_COMMIT_TAG} | sed -e "s/^WEBDEV-//" >> tags.txt
|
||||||
- echo "latest-dev" >> tags.txt
|
- echo "latest-dev"
|
||||||
- name: (YABA.Web) Determining Docker image version number (prod)
|
- name: (YABA.Web) Determining Docker image version number (prod)
|
||||||
when:
|
when:
|
||||||
- ref: refs/tags/WEB-*
|
- refs: refs/tags/WEB-*
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
commands:
|
commands:
|
||||||
- rm -f tags.txt
|
- rm -f tags.txt
|
||||||
- echo ${CI_COMMIT_TAG} | sed -e "s/^WEB-//" >> tags.txt
|
- echo ${CI_COMMIT_TAG} | sed -e "s/^WEB-//" >> tags.txt
|
||||||
- echo "latest" >> tags.txt
|
- echo "latest"
|
||||||
- name: (YABA.Web) Package and Upload Docker Image (dev)
|
- name: (YABA.Web) Package and Upload Docker Image
|
||||||
when:
|
|
||||||
- ref: refs/tags/WEBDEV-*
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
settings:
|
settings:
|
||||||
repo: gitea.iwanaga.moe/cjtibule/yaba/web
|
repo: gitea.iwanaga.moe/cjtibule/yaba/web
|
||||||
@ -32,21 +30,5 @@ steps:
|
|||||||
password:
|
password:
|
||||||
from_secret: gitea_yaba_registry_password
|
from_secret: gitea_yaba_registry_password
|
||||||
registry: gitea.iwanaga.moe
|
registry: gitea.iwanaga.moe
|
||||||
build_args:
|
build_args_from_env:
|
||||||
from_secret: DEV1_BUILDARGS
|
from_secret: DEV1_BUILDARGS
|
||||||
- name: (YABA.Web) Package and Upload Docker Image (prod)
|
|
||||||
when:
|
|
||||||
- ref: refs/tags/WEB-*
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
settings:
|
|
||||||
repo: gitea.iwanaga.moe/cjtibule/yaba/web
|
|
||||||
context: ./Web
|
|
||||||
dockerfile: ./Web/Dockerfile
|
|
||||||
tags_file: tags.txt
|
|
||||||
username:
|
|
||||||
from_secret: gitea_yaba_registry_username
|
|
||||||
password:
|
|
||||||
from_secret: gitea_yaba_registry_password
|
|
||||||
registry: gitea.iwanaga.moe
|
|
||||||
build_args:
|
|
||||||
from_secret: PROD_BUILDARGS
|
|
||||||
@ -6,16 +6,14 @@ EXPOSE 80
|
|||||||
EXPOSE 443
|
EXPOSE 443
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
ENV ASPNETCORE_Environment=
|
ENV ASPNETCORE_Environment=Development
|
||||||
ENV ASPNETCORE_Authentication__Auth0__ClientId=
|
ENV ASPNETCORE_Authentication__Auth0__ClientId=
|
||||||
ENV ASPNETCORE_Authentication__Auth0__ClientSecret=
|
ENV ASPNETCORE_Authentication__Auth0__ClientSecret=
|
||||||
ENV ASPNETCORE_Authentication__Auth0__Domain=
|
ENV ASPNETCORE_Authentication__Auth0__Domain=
|
||||||
ENV ASPNETCORE_Authentication__Auth0__Identifier=
|
ENV ASPNETCORE_Authentication__Auth0__Identifier=
|
||||||
ENV ASPNETCORE_ConnectionStrings__YABAReadOnlyDbConnectionString=
|
ENV ASPNETCORE_ConnectionStrings__YABAReadOnlyDbConnectionString=
|
||||||
ENV ASPNETCORE_ConnectionStrings__YABAReadWriteDbConnectionString=
|
ENV ASPNETCORE_ConnectionStrings__YABAReadWriteDbConnectionString=
|
||||||
ENV WebClient__Url=
|
ENV ASPNETCORE_WebClient__Url=
|
||||||
ENV Serilog__WriteTo__1__Args__Uri=
|
|
||||||
ENV Serilog__WriteTo__1__Args__Labels__1__Value=
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
using YABA.API.Extensions;
|
using YABA.API.Extensions;
|
||||||
using YABA.Common.Extensions;
|
using YABA.Common.Extensions;
|
||||||
using YABA.Common.Lookups;
|
using YABA.Common.Lookups;
|
||||||
using YABA.Common.Utils;
|
|
||||||
using YABA.Service.Interfaces;
|
using YABA.Service.Interfaces;
|
||||||
|
|
||||||
namespace YABA.API.Middlewares
|
namespace YABA.API.Middlewares
|
||||||
@ -32,7 +31,7 @@ namespace YABA.API.Middlewares
|
|||||||
userId = registedUser.Id;
|
userId = registedUser.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
httpContext.User.Identities.FirstOrDefault().AddClaim(new Claim(ClaimsLookup.UserId.GetClaimName(EnvironmentUtils.IsDevelopmentEnvironment()), userId.ToString()));
|
httpContext.User.Identities.FirstOrDefault().AddClaim(new Claim(ClaimsLookup.UserId.GetClaimName(), userId.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,13 +4,11 @@ namespace YABA.Common.Attributes
|
|||||||
{
|
{
|
||||||
public class ClaimNameAttribute : Attribute
|
public class ClaimNameAttribute : Attribute
|
||||||
{
|
{
|
||||||
public string DevClaimName { get; private set; }
|
public string Name { get; private set; }
|
||||||
public string ProdClaimName { get; private set; }
|
|
||||||
|
|
||||||
public ClaimNameAttribute(string devClaimName, string prodClaimName)
|
public ClaimNameAttribute(string name)
|
||||||
{
|
{
|
||||||
this.DevClaimName = devClaimName;
|
this.Name = name;
|
||||||
ProdClaimName = prodClaimName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,9 +28,9 @@ namespace YABA.Common.Extensions
|
|||||||
return enumValue.GetAttribute<DisplayAttribute>().Name;
|
return enumValue.GetAttribute<DisplayAttribute>().Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetClaimName(this ClaimsLookup claimLookup, bool isDevelopmentEnvironment)
|
public static string GetClaimName(this ClaimsLookup claimLookup)
|
||||||
{
|
{
|
||||||
return isDevelopmentEnvironment ? claimLookup.GetAttribute<ClaimNameAttribute>().DevClaimName : claimLookup.GetAttribute<ClaimNameAttribute>().ProdClaimName;
|
return claimLookup.GetAttribute<ClaimNameAttribute>().Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsCrudResultSuccessful(this CrudResultLookup importStatusLookup) => SuccessfulCrudStatuses.Contains(importStatusLookup);
|
public static bool IsCrudResultSuccessful(this CrudResultLookup importStatusLookup) => SuccessfulCrudStatuses.Contains(importStatusLookup);
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System.Security.Claims;
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using YABA.Common.Lookups;
|
using YABA.Common.Lookups;
|
||||||
using YABA.Common.Utils;
|
|
||||||
|
|
||||||
namespace YABA.Common.Extensions
|
namespace YABA.Common.Extensions
|
||||||
{
|
{
|
||||||
@ -14,7 +12,7 @@ namespace YABA.Common.Extensions
|
|||||||
public static string GetCustomClaim(this IIdentity identity, ClaimsLookup claim)
|
public static string GetCustomClaim(this IIdentity identity, ClaimsLookup claim)
|
||||||
{
|
{
|
||||||
var claimsIdentity = identity as ClaimsIdentity;
|
var claimsIdentity = identity as ClaimsIdentity;
|
||||||
return claimsIdentity.FindFirst(claim.GetClaimName(EnvironmentUtils.IsDevelopmentEnvironment()))?.Value.ToString();
|
return claimsIdentity.FindFirst(claim.GetClaimName())?.Value.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,19 +4,19 @@ namespace YABA.Common.Lookups
|
|||||||
{
|
{
|
||||||
public enum ClaimsLookup
|
public enum ClaimsLookup
|
||||||
{
|
{
|
||||||
[ClaimName("https://auth.dev.iwanaga.moe/api/auth_provider_id", "https://auth.iwanaga.moe/api/auth_provider_id")]
|
[ClaimNameAttribute("https://dev.iwanaga.moe/api/auth_provider_id")]
|
||||||
AuthProviderId = 1,
|
AuthProviderId = 1,
|
||||||
|
|
||||||
[ClaimName("https://auth.dev.iwanaga.moe/api/email_address", "https://auth.iwanaga.moe/api/email_address")]
|
[ClaimNameAttribute("https://dev.iwanaga.moe/api/email_address")]
|
||||||
UserEmail = 2,
|
UserEmail = 2,
|
||||||
|
|
||||||
[ClaimName("https://auth.dev.iwanaga.moe/api/email_verified", "https://auth.iwanaga.moe/api/email_verified")]
|
[ClaimNameAttribute("https://dev.iwanaga.moe/api/email_verified")]
|
||||||
IsEmailConfirmed = 3,
|
IsEmailConfirmed = 3,
|
||||||
|
|
||||||
[ClaimName("https://auth.dev.iwanaga.moe/api/username", "https://auth.iwanaga.moe/api/username")]
|
[ClaimNameAttribute("https://dev.iwanaga.moe/api/username")]
|
||||||
Username = 4,
|
Username = 4,
|
||||||
|
|
||||||
[ClaimName("https://auth.dev.iwanaga.moe/api/id", "https://auth.iwanaga.moe/api/id")]
|
[ClaimNameAttribute("https://dev.iwanaga.moe/api/id")]
|
||||||
UserId = 5
|
UserId = 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace YABA.Common.Utils
|
|
||||||
{
|
|
||||||
public static class EnvironmentUtils
|
|
||||||
{
|
|
||||||
public static bool IsDevelopmentEnvironment() => Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,5 +1,6 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
location / {
|
location / {
|
||||||
|
|||||||
Reference in New Issue
Block a user