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

fixed basic authentication logout #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/services/server_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (s *ServerService) Info(ctx context.Context, req *proto.InfoReq) (*proto.In
AllowedIps: allowedIPs(s.Config),
DnsEnabled: s.Config.DNS.Enabled,
DnsAddress: network.ServerVPNIP(s.Config.VPN.CIDR).IP.String(),
IsBasicProvider: strings.Contains(user.Provider, "basic"),
}, nil
}

Expand Down
51 changes: 30 additions & 21 deletions proto/proto/server.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions proto/server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ message InfoRes {
string allowed_ips = 7;
bool dns_enabled = 8;
string dns_address = 9;
bool is_basic_provider = 10;
}
10 changes: 9 additions & 1 deletion website/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const useStyles = makeStyles((theme) => ({
}));

export default function Navigation() {

function logout_basic() {
var req = new window.XMLHttpRequest()
req.open("HEAD", "/signin/0", false, "*", (new Date()).getTime().toString())
req.send("")
document.location.href = '/signout'
}

const classes = useStyles();
const hasAuthCookie = !!getCookie('auth-session');
return (
Expand Down Expand Up @@ -44,7 +52,7 @@ export default function Navigation() {
)}

{hasAuthCookie && (
<Link href="/signout" color="inherit">
<Link href='#' color="inherit" onClick={() => AppState.info?.isBasicProvider ? logout_basic() : document.location.href = '/signout'}>
<Button color="inherit">Logout</Button>
</Link>
)}
Expand Down
19 changes: 19 additions & 0 deletions website/src/sdk/server_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export declare namespace InfoRes {
allowedIps: string,
dnsEnabled: boolean,
dnsAddress: string,
isBasicProvider: boolean,
}
}

Expand Down Expand Up @@ -203,6 +204,14 @@ export class InfoRes extends jspb.Message {
(jspb.Message as any).setProto3StringField(this, 9, value);
}

getIsBasicProvider(): boolean {
return jspb.Message.getFieldWithDefault(this, 10, false);
}

setIsBasicProvider(value: boolean): void {
(jspb.Message as any).setProto3BooleanField(this, 10, value);
}

serializeBinary(): Uint8Array {
const writer = new jspb.BinaryWriter();
InfoRes.serializeBinaryToWriter(this, writer);
Expand All @@ -220,6 +229,7 @@ export class InfoRes extends jspb.Message {
allowedIps: this.getAllowedIps(),
dnsEnabled: this.getDnsEnabled(),
dnsAddress: this.getDnsAddress(),
isBasicProvider: this.getIsBasicProvider(),

};
}
Expand Down Expand Up @@ -261,6 +271,10 @@ export class InfoRes extends jspb.Message {
if (field9.length > 0) {
writer.writeString(9, field9);
}
const field10 = message.getIsBasicProvider();
if (field10 != false) {
writer.writeBool(10, field10);
}
}

static deserializeBinary(bytes: Uint8Array): InfoRes {
Expand Down Expand Up @@ -313,6 +327,10 @@ export class InfoRes extends jspb.Message {
const field9 = reader.readString()
message.setDnsAddress(field9);
break;
case 10:
const field10 = reader.readBool()
message.setIsBasicProvider(field10);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -346,6 +364,7 @@ function InfoResFromObject(obj: InfoRes.AsObject | undefined): InfoRes | undefin
message.setAllowedIps(obj.allowedIps);
message.setDnsEnabled(obj.dnsEnabled);
message.setDnsAddress(obj.dnsAddress);
message.setIsBasicProvider(obj.isBasicProvider);
return message;
}

Expand Down